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 disrupts gameplay flow. Magnet, Let me get that! provides synchronized attraction for ExperienceOrb entities.

+------------------+     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 ​

  1. Phase Shifting (NoClip): Experience orbs clip through solid blocks when pulled.
  2. Dynamic Acceleration: Experience orbs follow the same speed and acceleration lerp math.
  3. Line-of-Sight Filtering: When ig:magnet_los_only is true, XP orbs must pass LOS visibility checks.

🛡️ Performance & Lag Prevention (Particle Caps) ​

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: Governed by ig:magnet_max_particle_sources (default: 5).
  • Tick Staggering: Particles emit when (entity.tickCount + entity.getId()) % 4 == 0.

⚙️ Relevant Configuration & GameRules ​

GameRuleTypeDefaultDescription
ig:magnet_affects_xpBooleantrueWhether experience orbs are pulled by the magnet.
ig:magnet_particlesBooleantrueMaster toggle for electric spark visual trails.
ig:magnet_particle_countInteger1Number of spark particles spawned per active source.
ig:magnet_max_particle_sourcesInteger5Max simultaneous entities allowed to emit particles.

Official documentation & web portal for Dasik Igaijinn mods.