Skip to content

✨ Experience Orb Attraction (MC 26.1.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 Source Capig:magnet_max_particle_sources (Default: 5)

📖 Experience Vacuum Mechanics

Under the Instant Gratification philosophy, leaving experience orbs behind is counter to smooth gameplay. In Minecraft 26.1.2, ExperienceOrb entities are attracted with identical velocity and phase-shifting physics as 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

  1. Phase Shifting (NoClip): Experience orbs pass through solid blocks to avoid getting trapped behind walls or inside ceiling corners.
  2. Velocity Interpolation: Orbs accelerate smoothly toward player eye position using configured speed and acceleration percentages.
  3. LOS Gating: When ig:magnet_los_only is true, XP orbs must be visible to the player or have active magnetization momentum.

🛡️ Lag Prevention & Particle Pooling

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);
}
  • Max Particle Sources: Only the first $N$ entities per tick spawn visual trails.
  • Client-Safe Fallback: In MagnetMovement.java, if level is not a ServerLevel, particles fall back gracefully to level.addParticle(...).

⚙️ Relevant Configuration & GameRules

GameRuleTypeDefaultDescription
ig:magnet_affects_xpBooleantrueWhether the magnet attracts Experience Orbs.
ig:magnet_particlesBooleantrueMaster toggle for particle effects.
ig:magnet_particle_countInteger1Spark particles spawned per entity per particle tick.
ig:magnet_max_particle_sourcesInteger5Max entities allowed to emit particles simultaneously.

Official documentation & web portal for Dasik Igaijinn mods.