papermc/CraftBukkit-Patches/0009-Merge-tweaks-and-configuration.patch

97 lines
4.2 KiB
Diff
Raw Normal View History

2014-04-24 06:27:12 +00:00
From 786430e30804b7dee65a70750df4e95e1b35f546 Mon Sep 17 00:00:00 2001
2013-03-22 22:48:22 +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
2014-03-23 00:06:43 +00:00
index 8343ac9..95beb11 100644
2013-03-22 22:48:22 +00:00
--- a/src/main/java/net/minecraft/server/EntityItem.java
+++ b/src/main/java/net/minecraft/server/EntityItem.java
2013-12-01 03:40:53 +00:00
@@ -117,7 +117,10 @@ public class EntityItem extends Entity {
2013-03-22 22:48:22 +00:00
}
2013-12-01 03:40:53 +00:00
private void k() {
2013-03-22 22:48:22 +00:00
- Iterator iterator = this.world.a(EntityItem.class, this.boundingBox.grow(0.5D, 0.0D, 0.5D)).iterator();
+ // Spigot start
2013-06-21 07:00:01 +00:00
+ double radius = world.spigotConfig.itemMerge;
2013-03-22 22:48:22 +00:00
+ Iterator iterator = this.world.a(EntityItem.class, this.boundingBox.grow(radius, radius, radius)).iterator();
+ // Spigot end
while (iterator.hasNext()) {
EntityItem entityitem = (EntityItem) iterator.next();
2013-12-01 03:40:53 +00:00
@@ -148,11 +151,13 @@ public class EntityItem extends Entity {
2013-03-22 22:48:22 +00:00
} else if (itemstack1.count + itemstack.count > itemstack1.getMaxStackSize()) {
return false;
} else {
- 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
+ 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 {
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
2014-04-24 06:27:12 +00:00
index 93b7a72..61610f6 100644
2013-03-22 22:48:22 +00:00
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
2014-04-24 06:27:12 +00:00
@@ -1007,6 +1007,23 @@ public abstract class World implements IBlockAccess {
2013-03-22 22:48:22 +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;
2013-06-21 07:00:01 +00:00
+ double radius = spigotConfig.expMerge;
2013-03-22 22:48:22 +00:00
+ if (radius > 0) {
+ List<Entity> entities = this.getEntities(entity, entity.boundingBox.grow(radius, radius, radius));
+ 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;
2013-06-20 08:41:59 +00:00
diff --git a/src/main/java/org/spigotmc/SpigotWorldConfig.java b/src/main/java/org/spigotmc/SpigotWorldConfig.java
2014-03-09 22:14:45 +00:00
index 7e79ba5..1545a61 100644
2013-06-20 08:41:59 +00:00
--- a/src/main/java/org/spigotmc/SpigotWorldConfig.java
+++ b/src/main/java/org/spigotmc/SpigotWorldConfig.java
@@ -110,4 +110,18 @@ public class SpigotWorldConfig
2013-12-02 22:05:49 +00:00
saplingModifier = getAndValidateGrowth( "Sapling" );
wheatModifier = getAndValidateGrowth( "Wheat" );
2013-06-20 08:41:59 +00:00
}
+
2013-06-21 07:00:01 +00:00
+ public double itemMerge;
2013-06-20 08:41:59 +00:00
+ private void itemMerge()
+ {
2013-06-21 07:00:01 +00:00
+ itemMerge = getDouble("merge-radius.item", 2.5 );
2013-06-20 08:41:59 +00:00
+ log( "Item Merge Radius: " + itemMerge );
+ }
+
2013-06-21 07:00:01 +00:00
+ public double expMerge;
2013-06-20 08:41:59 +00:00
+ private void expMerge()
+ {
2013-06-21 07:00:01 +00:00
+ expMerge = getDouble("merge-radius.exp", 3.0 );
2013-06-20 08:41:59 +00:00
+ log( "Experience Merge Radius: " + expMerge );
+ }
}
2013-03-22 22:48:22 +00:00
--
2014-04-18 23:15:23 +00:00
1.9.1
2013-03-22 22:48:22 +00:00