summaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/net/minecraft/server/EntityLiving.java27
-rw-r--r--src/main/java/net/minecraft/server/EntityPigZombie.java29
-rw-r--r--src/main/java/net/minecraft/server/EntitySkeleton.java27
-rw-r--r--src/main/java/net/minecraft/server/EntityZombie.java28
4 files changed, 77 insertions, 34 deletions
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
index 22bf409f..a48ff67b 100644
--- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
@@ -9,6 +9,7 @@ import java.util.Random;
// CraftBukkit start
import org.bukkit.craftbukkit.TrigMath;
import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.event.entity.EntityDamageByBlockEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityRegainHealthEvent;
@@ -778,20 +779,18 @@ public abstract class EntityLiving extends Entity {
if (!this.isBaby()) {
this.dropDeathLoot(this.lastDamageByPlayerTime > 0, i);
- if (this.lastDamageByPlayerTime > 0) {
- int j = this.random.nextInt(200) - i;
-
- if (j < 5) {
- this.b(j <= 0 ? 1 : 0);
- }
- }
+ // CraftBukkit - move rare item drop call to dropDeathLoot
}
}
this.world.broadcastEntityEffect(this, (byte) 3);
}
- protected void b(int i) {}
+ // CraftBukkit start - change return type to ItemStack
+ protected ItemStack b(int i) {
+ return null;
+ }
+ // CraftBukkit end
protected void dropDeathLoot(boolean flag, int i) {
int j = this.getLootId();
@@ -811,6 +810,18 @@ public abstract class EntityLiving extends Entity {
}
}
+ // Determine rare item drops and add them to the loot
+ if (this.lastDamageByPlayerTime > 0) {
+ int k = this.random.nextInt(200) - i;
+
+ if (k < 5) {
+ ItemStack itemstack = this.b(k <= 0 ? 1 : 0);
+ if (itemstack != null) {
+ loot.add(new CraftItemStack(itemstack));
+ }
+ }
+ }
+
CraftEventFactory.callEntityDeathEvent(this, loot); // raise event even for those times when the entity does not drop loot
// CraftBukkit end
}
diff --git a/src/main/java/net/minecraft/server/EntityPigZombie.java b/src/main/java/net/minecraft/server/EntityPigZombie.java
index 0988afbc..7485b632 100644
--- a/src/main/java/net/minecraft/server/EntityPigZombie.java
+++ b/src/main/java/net/minecraft/server/EntityPigZombie.java
@@ -120,8 +120,6 @@ public class EntityPigZombie extends EntityZombie {
List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>();
int j = this.random.nextInt(2 + i);
- int k;
-
if (j > 0) {
loot.add(new CraftItemStack(Item.ROTTEN_FLESH.id, j));
}
@@ -131,28 +129,45 @@ public class EntityPigZombie extends EntityZombie {
if (j > 0) {
loot.add(new CraftItemStack(Item.GOLD_NUGGET.id, j));
}
+
+ // Determine rare item drops and add them to the loot
+ if (this.lastDamageByPlayerTime > 0) {
+ int k = this.random.nextInt(200) - i;
+
+ if (k < 5) {
+ ItemStack itemstack = this.b(k <= 0 ? 1 : 0);
+ if (itemstack != null) {
+ loot.add(new CraftItemStack(itemstack));
+ }
+ }
+ }
+
CraftEventFactory.callEntityDeathEvent(this, loot);
// CraftBukkit end
}
- protected void b(int i) {
+ // CraftBukkit start - return rare dropped item instead of dropping it
+ protected ItemStack b(int i) {
if (i > 0) {
ItemStack itemstack = new ItemStack(Item.GOLD_SWORD);
EnchantmentManager.a(this.random, itemstack, 5);
- this.a(itemstack, 0.0F);
+ return itemstack;
} else {
int j = this.random.nextInt(3);
if (j == 0) {
- this.b(Item.GOLD_INGOT.id, 1);
+ return new ItemStack(Item.GOLD_INGOT.id, 1, 0);
} else if (j == 1) {
- this.b(Item.GOLD_SWORD.id, 1);
+ return new ItemStack(Item.GOLD_SWORD.id, 1, 0);
} else if (j == 2) {
- this.b(Item.GOLD_HELMET.id, 1);
+ return new ItemStack(Item.GOLD_HELMET.id, 1, 0);
+ } else {
+ return null;
}
}
}
+ // CraftBukkit end
protected int getLootId() {
return Item.ROTTEN_FLESH.id;
diff --git a/src/main/java/net/minecraft/server/EntitySkeleton.java b/src/main/java/net/minecraft/server/EntitySkeleton.java
index 58a15bde..82b663fa 100644
--- a/src/main/java/net/minecraft/server/EntitySkeleton.java
+++ b/src/main/java/net/minecraft/server/EntitySkeleton.java
@@ -1,5 +1,10 @@
package net.minecraft.server;
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+// CraftBukkit end
+
public class EntitySkeleton extends EntityMonster {
private static final ItemStack a = new ItemStack(Item.BOW, 1);
@@ -93,18 +98,32 @@ public class EntitySkeleton extends EntityMonster {
loot.add(new org.bukkit.inventory.ItemStack(org.bukkit.Material.BONE, count));
}
- org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDeathEvent(this, loot);
+ // Determine rare item drops and add them to the loot
+ if (this.lastDamageByPlayerTime > 0) {
+ int k = this.random.nextInt(200) - i;
+
+ if (k < 5) {
+ ItemStack itemstack = this.b(k <= 0 ? 1 : 0);
+ if (itemstack != null) {
+ loot.add(new CraftItemStack(itemstack));
+ }
+ }
+ }
+
+ CraftEventFactory.callEntityDeathEvent(this, loot);
// CraftBukkit end
}
- protected void b(int i) {
+ // CraftBukkit start - return rare dropped item instead of dropping it
+ protected ItemStack b(int i) {
if (i > 0) {
ItemStack itemstack = new ItemStack(Item.BOW);
EnchantmentManager.a(this.random, itemstack, 5);
- this.a(itemstack, 0.0F);
+ return itemstack;
} else {
- this.b(Item.BOW.id, 1);
+ return new ItemStack(Item.BOW.id, 1, 0);
}
}
+ // CraftBukkit end
}
diff --git a/src/main/java/net/minecraft/server/EntityZombie.java b/src/main/java/net/minecraft/server/EntityZombie.java
index 6c053498..2d43731c 100644
--- a/src/main/java/net/minecraft/server/EntityZombie.java
+++ b/src/main/java/net/minecraft/server/EntityZombie.java
@@ -75,22 +75,20 @@ public class EntityZombie extends EntityMonster {
return MonsterType.UNDEAD;
}
- protected void b(int i) {
+ // CraftBukkit start - return rare dropped item instead of dropping it
+ protected ItemStack b(int i) {
switch (this.random.nextInt(4)) {
- case 0:
- this.b(Item.IRON_SWORD.id, 1);
- break;
-
- case 1:
- this.b(Item.IRON_HELMET.id, 1);
- break;
-
- case 2:
- this.b(Item.IRON_INGOT.id, 1);
- break;
-
- case 3:
- this.b(Item.IRON_SPADE.id, 1);
+ case 0:
+ return new ItemStack(Item.IRON_SWORD.id, 1, 0);
+ case 1:
+ return new ItemStack(Item.IRON_HELMET.id, 1, 0);
+ case 2:
+ return new ItemStack(Item.IRON_INGOT.id, 1, 0);
+ case 3:
+ return new ItemStack(Item.IRON_SPADE.id, 1, 0);
+ default:
+ return null;
}
}
+ // CraftBukkit end
}