Paper/CraftBukkit-Patches/0018-Better-more-flexible-itemstack-merging.patch

94 lines
4.7 KiB
Diff
Raw Normal View History

2013-03-20 22:54:12 +01:00
From a4b236f3fce26060a2a4751d6fa0f113c6cc75e6 Mon Sep 17 00:00:00 2001
2013-01-21 04:32:12 +01:00
From: md_5 <md_5@live.com.au>
2013-01-25 08:25:18 +01:00
Date: Fri, 25 Jan 2013 18:24:54 +1100
2013-01-21 04:32:12 +01:00
Subject: [PATCH] Better + more flexible itemstack merging
---
2013-01-25 08:25:18 +01:00
src/main/java/net/minecraft/server/EntityItem.java | 13 ++++-----
src/main/java/net/minecraft/server/World.java | 31 +++-------------------
2 files changed, 11 insertions(+), 33 deletions(-)
2013-01-21 04:32:12 +01:00
diff --git a/src/main/java/net/minecraft/server/EntityItem.java b/src/main/java/net/minecraft/server/EntityItem.java
index aa8d83f..bc69f5d 100644
2013-01-21 04:32:12 +01:00
--- a/src/main/java/net/minecraft/server/EntityItem.java
+++ b/src/main/java/net/minecraft/server/EntityItem.java
@@ -114,7 +114,8 @@ public class EntityItem extends Entity {
}
private void g() {
- Iterator iterator = this.world.a(EntityItem.class, this.boundingBox.grow(0.5D, 0.0D, 0.5D)).iterator();
+ double radius = world.getWorld().itemMergeRadius;
+ Iterator iterator = this.world.a(EntityItem.class, this.boundingBox.grow(radius, radius, radius)).iterator();
while (iterator.hasNext()) {
EntityItem entityitem = (EntityItem) iterator.next();
@@ -143,11 +144,11 @@ public class EntityItem extends Entity {
} 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();
+ 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();
return true;
}
} else {
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
2013-03-20 22:54:12 +01:00
index b5c5e36..ba37de6 100644
2013-01-21 04:32:12 +01:00
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -948,31 +948,8 @@ public abstract class World implements IBlockAccess {
2013-01-25 08:25:18 +01:00
event = CraftEventFactory.callCreatureSpawnEvent((EntityLiving) entity, spawnReason);
2013-01-21 04:32:12 +01:00
} else if (entity instanceof EntityItem) {
event = CraftEventFactory.callItemSpawnEvent((EntityItem) entity);
2013-01-25 08:25:18 +01:00
- // Spigot start
2013-01-21 04:32:12 +01:00
- ItemStack item = ((EntityItem) entity).getItemStack();
- org.bukkit.craftbukkit.inventory.CraftItemStack craft = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(item);
- int maxSize = item.getMaxStackSize();
- if (item.count < maxSize) {
- double radius = this.getWorld().itemMergeRadius;
- if (radius > 0) {
- List<Entity> entities = this.getEntities(entity, entity.boundingBox.grow(radius, radius, radius));
- for (Entity e : entities) {
- if (e instanceof EntityItem) {
- EntityItem loopItem = (EntityItem) e;
- ItemStack loopStack = loopItem.getItemStack();
- if (!loopItem.dead && craft.isSimilar(org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(loopStack))) {
- int toAdd = Math.min(loopStack.count, maxSize - item.count);
- item.count += toAdd;
- loopStack.count -= toAdd;
- if (loopStack.count <= 0) {
- loopItem.die();
- }
- }
- }
- }
- }
- }
- } else if (entity instanceof EntityExperienceOrb) {
2013-01-25 08:25:18 +01:00
+ } // Spigot start
+ if (entity instanceof EntityExperienceOrb) {
2013-01-21 04:32:12 +01:00
EntityExperienceOrb xp = (EntityExperienceOrb) entity;
double radius = this.getWorld().expMergeRadius;
if (radius > 0) {
@@ -987,8 +964,8 @@ public abstract class World implements IBlockAccess {
2013-01-21 04:32:12 +01:00
}
}
}
2013-01-25 08:25:18 +01:00
- // Spigot end
- } else if (entity.getBukkitEntity() instanceof org.bukkit.entity.Projectile) {
+ } // Spigot end
+ else if (entity.getBukkitEntity() instanceof org.bukkit.entity.Projectile) {
2013-01-21 04:32:12 +01:00
// Not all projectiles extend EntityProjectile, so check for Bukkit interface instead
2013-01-25 08:25:18 +01:00
event = CraftEventFactory.callProjectileLaunchEvent(entity);
}
2013-01-21 04:32:12 +01:00
--
2013-03-20 22:54:12 +01:00
1.8.2
2013-01-21 04:32:12 +01:00