Merge tweaks and configuration

This allows the merging of Experience orbs, as well as the configuration of the merge radius of items. Additionally it refactors the merge algorithm to be a better experience for players.

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2013-03-23 09:46:33 +11:00
parent df403168ff
commit 973f52a650
3 changed files with 57 additions and 5 deletions

View File

@@ -703,6 +703,23 @@ public class CraftEventFactory {
return false;
}
// Spigot start - SPIGOT-7523: Merge after spawn event and only merge if the event was not cancelled (gets checked above)
if (entity instanceof net.minecraft.world.entity.ExperienceOrb xp) {
double radius = world.spigotConfig.expMerge;
if (radius > 0) {
List<Entity> entities = world.getEntities(entity, entity.getBoundingBox().inflate(radius, radius, radius));
for (Entity e : entities) {
if (e instanceof net.minecraft.world.entity.ExperienceOrb loopItem) {
if (!loopItem.isRemoved()) {
xp.value += loopItem.value;
loopItem.discard(null); // Add Bukkit remove cause
}
}
}
}
}
// Spigot end
return true;
}