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;
}

View File

@@ -134,4 +134,18 @@ public class SpigotWorldConfig
this.weepingVinesModifier = this.getAndValidateGrowth( "WeepingVines" );
this.caveVinesModifier = this.getAndValidateGrowth( "CaveVines" );
}
public double itemMerge;
private void itemMerge()
{
this.itemMerge = this.getDouble("merge-radius.item", 2.5 );
this.log( "Item Merge Radius: " + this.itemMerge );
}
public double expMerge;
private void expMerge()
{
this.expMerge = this.getDouble("merge-radius.exp", 3.0 );
this.log( "Experience Merge Radius: " + this.expMerge );
}
}