diff options
Diffstat (limited to 'src/main/java/net/minecraft/server/EntityItem.java')
-rw-r--r-- | src/main/java/net/minecraft/server/EntityItem.java | 87 |
1 files changed, 51 insertions, 36 deletions
diff --git a/src/main/java/net/minecraft/server/EntityItem.java b/src/main/java/net/minecraft/server/EntityItem.java index cecd16d8..93f93863 100644 --- a/src/main/java/net/minecraft/server/EntityItem.java +++ b/src/main/java/net/minecraft/server/EntityItem.java @@ -59,7 +59,7 @@ public class EntityItem extends Entity { this.lastY = this.locY; this.lastZ = this.locZ; this.motY -= 0.03999999910593033D; - this.i(this.locX, (this.boundingBox.b + this.boundingBox.e) / 2.0D, this.locZ); + this.Y = this.i(this.locX, (this.boundingBox.b + this.boundingBox.e) / 2.0D, this.locZ); this.move(this.motX, this.motY, this.motZ); boolean flag = (int) this.lastX != (int) this.locX || (int) this.lastY != (int) this.locY || (int) this.lastZ != (int) this.locZ; @@ -68,17 +68,11 @@ public class EntityItem extends Entity { this.motY = 0.20000000298023224D; this.motX = (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F); this.motZ = (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.2F); - this.world.makeSound(this, "random.fizz", 0.4F, 2.0F + this.random.nextFloat() * 0.4F); + this.makeSound("random.fizz", 0.4F, 2.0F + this.random.nextFloat() * 0.4F); } if (!this.world.isStatic) { - Iterator iterator = this.world.a(EntityItem.class, this.boundingBox.grow(0.5D, 0.0D, 0.5D)).iterator(); - - while (iterator.hasNext()) { - EntityItem entityitem = (EntityItem) iterator.next(); - - this.a(entityitem); - } + this.d(); } } @@ -112,32 +106,42 @@ public class EntityItem extends Entity { } } + private void d() { + Iterator iterator = this.world.a(EntityItem.class, this.boundingBox.grow(0.5D, 0.0D, 0.5D)).iterator(); + + while (iterator.hasNext()) { + EntityItem entityitem = (EntityItem) iterator.next(); + + this.a(entityitem); + } + } + public boolean a(EntityItem entityitem) { if (entityitem == this) { return false; } else if (entityitem.isAlive() && this.isAlive()) { if (entityitem.itemStack.getItem() != this.itemStack.getItem()) { return false; - } else if (!entityitem.itemStack.hasTag() && !this.itemStack.hasTag()) { - if (entityitem.itemStack.getItem().l() && entityitem.itemStack.getData() != this.itemStack.getData()) { - return false; - } else if (entityitem.itemStack.count < this.itemStack.count) { - return entityitem.a(this); - } else if (entityitem.itemStack.count + this.itemStack.count > entityitem.itemStack.getMaxStackSize()) { - return false; - // CraftBukkit start - don't merge items with enchantments - } else if (entityitem.itemStack.hasEnchantments() || this.itemStack.hasEnchantments()) { - return false; - // CraftBukkit end - } else { - entityitem.itemStack.count += this.itemStack.count; - entityitem.pickupDelay = Math.max(entityitem.pickupDelay, this.pickupDelay); - entityitem.age = Math.min(entityitem.age, this.age); - this.die(); - return true; - } - } else { + } else if (entityitem.itemStack.hasTag() ^ this.itemStack.hasTag()) { + return false; + } else if (entityitem.itemStack.hasTag() && !entityitem.itemStack.getTag().equals(this.itemStack.getTag())) { + return false; + } else if (entityitem.itemStack.getItem().l() && entityitem.itemStack.getData() != this.itemStack.getData()) { + return false; + } else if (entityitem.itemStack.count < this.itemStack.count) { + return entityitem.a(this); + } else if (entityitem.itemStack.count + this.itemStack.count > entityitem.itemStack.getMaxStackSize()) { return false; + // CraftBukkit start - don't merge items with enchantments + } else if (entityitem.itemStack.hasEnchantments() || this.itemStack.hasEnchantments()) { + return false; + // CraftBukkit end + } else { + entityitem.itemStack.count += this.itemStack.count; + entityitem.pickupDelay = Math.max(entityitem.pickupDelay, this.pickupDelay); + entityitem.age = Math.min(entityitem.age, this.age); + this.die(); + return true; } } else { return false; @@ -157,13 +161,17 @@ public class EntityItem extends Entity { } public boolean damageEntity(DamageSource damagesource, int i) { - this.K(); - this.e -= i; - if (this.e <= 0) { - this.die(); - } + if (this.isInvulnerable()) { + return false; + } else { + this.K(); + this.e -= i; + if (this.e <= 0) { + this.die(); + } - return false; + return false; + } } public void b(NBTTagCompound nbttagcompound) { @@ -185,7 +193,7 @@ public class EntityItem extends Entity { } } - public void b_(EntityHuman entityhuman) { + public void c_(EntityHuman entityhuman) { if ((!this.world.isStatic) && (this.itemStack != null)) { // CraftBukkit - nullcheck int i = this.itemStack.count; @@ -225,7 +233,7 @@ public class EntityItem extends Entity { entityhuman.a((Statistic) AchievementList.z); } - this.world.makeSound(this, "random.pop", 0.2F, ((this.random.nextFloat() - this.random.nextFloat()) * 0.7F + 1.0F) * 2.0F); + this.makeSound("random.pop", 0.2F, ((this.random.nextFloat() - this.random.nextFloat()) * 0.7F + 1.0F) * 2.0F); entityhuman.receive(this, i); if (this.itemStack.count <= 0) { this.die(); @@ -242,4 +250,11 @@ public class EntityItem extends Entity { public boolean aq() { return false; } + + public void b(int i) { + super.b(i); + if (!this.world.isStatic) { + this.d(); + } + } } |