summaryrefslogtreecommitdiffstats
path: root/src/main/java/net/minecraft/server/EntitySheep.java
diff options
context:
space:
mode:
authorCeltic Minstrel <celtic.minstrel.ca@some.place>2012-03-05 14:21:43 -0500
committerEvilSeph <evilseph@gmail.com>2012-03-21 12:42:51 -0400
commit5ba892804158ba81b655826469363eefa8f0baaa (patch)
tree75daade710326db6487550877a21a8557951bc52 /src/main/java/net/minecraft/server/EntitySheep.java
parent8d62de7055a8c901240412ac41f3cb5091ea41a9 (diff)
downloadcraftbukkit-5ba892804158ba81b655826469363eefa8f0baaa.tar
craftbukkit-5ba892804158ba81b655826469363eefa8f0baaa.tar.gz
craftbukkit-5ba892804158ba81b655826469363eefa8f0baaa.tar.lz
craftbukkit-5ba892804158ba81b655826469363eefa8f0baaa.tar.xz
craftbukkit-5ba892804158ba81b655826469363eefa8f0baaa.zip
[Bleeding] Added getting and setting drops to all appropriate events. Fixes BUKKIT-397 and fixes BUKKIT-1252
- Allows drops in creative mode by adding items to the getDrops() list - Contents of containers are not reported - Contents of storage minecarts are not reported
Diffstat (limited to 'src/main/java/net/minecraft/server/EntitySheep.java')
-rw-r--r--src/main/java/net/minecraft/server/EntitySheep.java19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/main/java/net/minecraft/server/EntitySheep.java b/src/main/java/net/minecraft/server/EntitySheep.java
index 59f3eb9c..62e641ba 100644
--- a/src/main/java/net/minecraft/server/EntitySheep.java
+++ b/src/main/java/net/minecraft/server/EntitySheep.java
@@ -3,8 +3,12 @@ package net.minecraft.server;
import java.util.Random;
// CraftBukkit start
+import java.util.ArrayList;
+import java.util.List;
+
import org.bukkit.Material;
import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.entity.Sheep;
// CraftBukkit end
@@ -80,7 +84,12 @@ public class EntitySheep extends EntityAnimal {
if (itemstack != null && itemstack.id == Item.SHEARS.id && !this.isSheared() && !this.isBaby()) {
if (!this.world.isStatic) {
// CraftBukkit start
- org.bukkit.event.player.PlayerShearEntityEvent event = new org.bukkit.event.player.PlayerShearEntityEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), this.getBukkitEntity());
+ int i = 1 + this.random.nextInt(3);
+ List<org.bukkit.inventory.ItemStack> drops = new ArrayList<org.bukkit.inventory.ItemStack>();
+ for (int j = 0; j < i; ++j) {
+ drops.add(new CraftItemStack(Block.WOOL.id, 1, (short) this.getColor()));
+ }
+ org.bukkit.event.player.PlayerShearEntityEvent event = new org.bukkit.event.player.PlayerShearEntityEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), this.getBukkitEntity(), drops);
this.world.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
@@ -89,11 +98,15 @@ public class EntitySheep extends EntityAnimal {
// CraftBukkit end
this.setSheared(true);
+ /* CraftBukkit start - Moved this line to before the event is fired
int i = 1 + this.random.nextInt(3);
-
+ // And this logic is changed to use the drop list from the event
for (int j = 0; j < i; ++j) {
EntityItem entityitem = this.a(new ItemStack(Block.WOOL.id, 1, this.getColor()), 1.0F);
-
+ // */
+ for (org.bukkit.inventory.ItemStack stack : drops) {
+ EntityItem entityitem = this.a(CraftItemStack.createNMSItemStack(stack), 1.0f);
+ // CraftBukkit end
entityitem.motY += (double) (this.random.nextFloat() * 0.05F);
entityitem.motX += (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F);
entityitem.motZ += (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F);