2015-07-27 12:20:54 +00:00
From 132c9f128e9b958ba9161738329c811f68553833 Mon Sep 17 00:00:00 2001
2014-07-21 20:46:54 +00:00
From: md_5 <md_5@live.com.au>
Date: Sat, 23 Mar 2013 09:46:33 +1100
Subject: [PATCH] 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.
diff --git a/src/main/java/net/minecraft/server/EntityItem.java b/src/main/java/net/minecraft/server/EntityItem.java
2015-07-12 09:59:20 +00:00
index 1eda0ef..8b7cd86 100644
2014-07-21 20:46:54 +00:00
--- a/src/main/java/net/minecraft/server/EntityItem.java
+++ b/src/main/java/net/minecraft/server/EntityItem.java
2015-06-06 09:47:02 +00:00
@@ -122,7 +122,10 @@ public class EntityItem extends Entity {
2014-07-21 20:46:54 +00:00
}
2014-11-28 01:17:45 +00:00
private void w() {
- Iterator iterator = this.world.a(EntityItem.class, this.getBoundingBox().grow(0.5D, 0.0D, 0.5D)).iterator();
2014-07-21 20:46:54 +00:00
+ // Spigot start
+ double radius = world.spigotConfig.itemMerge;
2014-11-28 01:17:45 +00:00
+ Iterator iterator = this.world.a(EntityItem.class, this.getBoundingBox().grow(radius, radius, radius)).iterator();
2014-07-21 20:46:54 +00:00
+ // Spigot end
while (iterator.hasNext()) {
EntityItem entityitem = (EntityItem) iterator.next();
2015-07-12 09:59:20 +00:00
@@ -156,12 +159,14 @@ public class EntityItem extends Entity {
2014-11-28 01:17:45 +00:00
} else if (itemstack1.count + itemstack.count > itemstack1.getMaxStackSize()) {
return false;
} else {
2015-07-12 09:59:20 +00:00
- if (org.bukkit.craftbukkit.event.CraftEventFactory.callItemMergeEvent(this, entityitem).isCancelled()) return false; // CraftBukkit
2014-11-28 01:17:45 +00:00
- itemstack1.count += itemstack.count;
- entityitem.pickupDelay = Math.max(entityitem.pickupDelay, this.pickupDelay);
- entityitem.age = Math.min(entityitem.age, this.age);
- entityitem.setItemStack(itemstack1);
- this.die();
+ // Spigot start
2015-07-12 09:59:20 +00:00
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callItemMergeEvent(entityitem, this).isCancelled()) return false; // CraftBukkit
2014-11-28 01:17:45 +00:00
+ itemstack.count += itemstack1.count;
+ this.pickupDelay = Math.max(entityitem.pickupDelay, this.pickupDelay);
+ this.age = Math.min(entityitem.age, this.age);
+ this.setItemStack(itemstack);
+ entityitem.die();
+ // Spigot end
return true;
}
} else {
2014-07-21 20:46:54 +00:00
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
2015-07-12 09:59:20 +00:00
index 5cb66a5..75d335f 100644
2014-07-21 20:46:54 +00:00
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
2015-03-16 10:19:21 +00:00
@@ -970,6 +970,23 @@ public abstract class World implements IBlockAccess {
2014-07-21 20:46:54 +00:00
// Not all projectiles extend EntityProjectile, so check for Bukkit interface instead
event = CraftEventFactory.callProjectileLaunchEvent(entity);
}
+ // Spigot start
+ else if (entity instanceof EntityExperienceOrb) {
+ EntityExperienceOrb xp = (EntityExperienceOrb) entity;
+ double radius = spigotConfig.expMerge;
+ if (radius > 0) {
2014-11-28 01:17:45 +00:00
+ List<Entity> entities = this.getEntities(entity, entity.getBoundingBox().grow(radius, radius, radius));
2014-07-21 20:46:54 +00:00
+ for (Entity e : entities) {
+ if (e instanceof EntityExperienceOrb) {
+ EntityExperienceOrb loopItem = (EntityExperienceOrb) e;
+ if (!loopItem.dead) {
+ xp.value += loopItem.value;
+ loopItem.die();
+ }
+ }
+ }
+ }
+ } // Spigot end
if (event != null && (event.isCancelled() || entity.dead)) {
entity.dead = true;
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
2015-05-26 09:16:27 +00:00
index 5749a45..7322703 100644
2014-07-21 20:46:54 +00:00
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
2015-05-26 09:16:27 +00:00
@@ -112,4 +112,18 @@ public class SpigotWorldConfig
2014-07-21 20:46:54 +00:00
wheatModifier = getAndValidateGrowth( "Wheat" );
2015-05-26 09:16:27 +00:00
wartModifier = getAndValidateGrowth( "NetherWart" );
2014-07-21 20:46:54 +00:00
}
+
+ public double itemMerge;
+ private void itemMerge()
+ {
+ itemMerge = getDouble("merge-radius.item", 2.5 );
+ log( "Item Merge Radius: " + itemMerge );
+ }
+
+ public double expMerge;
+ private void expMerge()
+ {
+ expMerge = getDouble("merge-radius.exp", 3.0 );
+ log( "Experience Merge Radius: " + expMerge );
+ }
}
--
2015-05-09 20:23:26 +00:00
2.1.4
2014-07-21 20:46:54 +00:00