Skip to content

✨ 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 InfoboxTechnical Parameters
Target Entity Classnet.minecraft.world.entity.ExperienceOrb
Manager Classnet.instantgratification.magnet.MagnetManager
Enabling GameRuleig:magnet_affects_xp (Default: true)
Scanning Queryplayer.level().getEntitiesOfClass(ExperienceOrb.class, area, Entity::isAlive)
Particle TypeParticleTypes.ELECTRIC_SPARK
Particle ThrottleShared 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:

java
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

GameRuleTypeDefaultUnit / RangeDescription
ig:magnet_affects_xpBooleantruetrue/falseWhether experience orbs are pulled by the magnet.
ig:magnet_particlesBooleantruetrue/falseMaster toggle for electric spark visual trails.
ig:magnet_particle_countInteger10..100Number of spark particles spawned per active source.
ig:magnet_max_particle_sourcesInteger50..100Max simultaneous entities allowed to emit particles.

Official documentation & web portal for Dasik Igaijinn mods.