-
Notifications
You must be signed in to change notification settings - Fork 0
26.2 Experience Orb Attraction
π Repository Source Disclaimer: The documentation in this Wiki reflects the current source code state in the repository, which may include recent unreleased commits or developmental features ahead of public release builds on CurseForge and Modrinth.
| Feature Infobox | Technical Parameters |
|---|---|
| Target Entity Class | net.minecraft.world.entity.ExperienceOrb |
| Manager Class | net.instantgratification.magnet.MagnetManager |
| Enabling GameRule |
ig:magnet_affects_xp (Default: true) |
| Scanning Query | player.level().getEntitiesOfClass(ExperienceOrb.class, area, Entity::isAlive) |
| Particle Type | ParticleTypes.ELECTRIC_SPARK |
| Particle Throttle | Shared with items via ig:magnet_max_particle_sources
|
Under the Instant Gratification philosophy, leaving experience orbs scattered on the ground or stuck on cave ceilings disrupts gameplay flow. Magnet, Let me get that! provides first-class support for attracting ExperienceOrb entities alongside dropped items.
+------------------+ getEntitiesOfClass +-----------------------+ MagnetMovement.pull +--------------------+
| Player Scan AABB | -------------------------> | List<ExperienceOrb> | --------------------------> | Player Collection |
+------------------+ +-----------------------+ +--------------------+
|
v
[Apply NoClip Phase-Shift]
[Apply Lerp Velocity Vector]
[Throttled Spark Particles]
When ig:magnet_affects_xp is enabled, all experience orbs in range inherit the exact same advanced mechanics as dropped items:
- Phase Shifting (NoClip): Experience orbs clip through solid blocks when pulled, preventing them from orbiting or bouncing endlessly against walls.
-
Dynamic Acceleration: Experience orbs follow the same speed (
$s = \text{speed}/100.0$ ) and acceleration ($a = \text{accel}/100.0$ ) lerp calculations. -
Line-of-Sight Filtering: If
ig:magnet_los_onlyis true, XP orbs must pass both the primary 360Β° raycast and secondary granular checks.
High-density mob farms or Ender Dragon boss fights can generate hundreds of individual experience orbs simultaneously. Spawning particles on every orb per tick could cause severe client FPS drops.
The mod prevents particle lag through Global Particle Source Throttling:
int maxParticleSources = ModGameRules.getInt(player.level(), ModGameRules.MAGNET_MAX_PARTICLE_SOURCES);
int particleSourceCount = 0;
for (ExperienceOrb orb : orbs) {
boolean shouldSpawnParticles = false;
if (particleSourceCount < maxParticleSources) {
shouldSpawnParticles = true;
particleSourceCount++;
}
MagnetMovement.pull(orb, player, shouldSpawnParticles);
}-
Global Cap: Only the first
$N$ entities (configured byig:magnet_max_particle_sources, default:5) are permitted to emit spark particles on any given tick. -
Tick Staggering: Particles are only emitted when
(entity.tickCount + entity.getId()) % 4 == 0(every 4 ticks = 5 times per second).
| GameRule | Type | Default | Unit / Range | Description |
|---|---|---|---|---|
ig:magnet_affects_xp |
Boolean | true |
true/false |
Whether experience orbs are pulled by the magnet. |
ig:magnet_particles |
Boolean | true |
true/false |
Master toggle for electric spark visual trails. |
ig:magnet_particle_count |
Integer | 1 |
0..100 |
Number of spark particles spawned per active source. |
ig:magnet_max_particle_sources |
Integer | 5 |
0..100 |
Max simultaneous entities allowed to emit particles. |
Magnet, Let me get that! β’ Developed by Dasik (Rifaditya) β’ Licensed under GNU GPLv3
Documentation reflects active repository source code. Features may precede public releases on CurseForge/Modrinth.
- π 26.2 Overview
- Gameplay Mechanics
- Administration & Config
- Technical & Development
- π 26.1.2 Overview
- Gameplay Mechanics
- Administration & Config
- Technical & Development