Skip to content

26.2 Experience Orb Attraction

Rifa edited this page Aug 22, 2026 · 1 revision

✨ Experience Orb Attraction (MC 26.2)

πŸ“Œ 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

πŸ“– Experience Vacuum Mechanics

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]

⚑ Synchronized Physics & Phase Shifting

When ig:magnet_affects_xp is enabled, all experience orbs in range inherit the exact same advanced mechanics as dropped items:

  1. Phase Shifting (NoClip): Experience orbs clip through solid blocks when pulled, preventing them from orbiting or bouncing endlessly against walls.
  2. Dynamic Acceleration: Experience orbs follow the same speed ($s = \text{speed}/100.0$) and acceleration ($a = \text{accel}/100.0$) lerp calculations.
  3. Line-of-Sight Filtering: If ig:magnet_los_only is true, XP orbs must pass both the primary 360Β° raycast and secondary granular checks.

πŸ›‘οΈ Performance & Lag Prevention (Particle Caps)

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 by ig: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).

βš™οΈ Relevant Configuration & GameRules

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.

πŸ”— Related Wiki Documentation

Clone this wiki locally