diff options
author | EvilSeph <evilseph@gmail.com> | 2012-01-23 19:51:36 -0500 |
---|---|---|
committer | EvilSeph <evilseph@gmail.com> | 2012-01-23 22:41:34 -0500 |
commit | 97ce5c447993b2a7f5cc32764b091ccf55365f0c (patch) | |
tree | c6ce1a0ca311d7b80707b5210afa621bd5bc78b8 | |
parent | 93bc8ecd93a9b495a8fbc76b8ccf589418a450f3 (diff) | |
download | craftbukkit-97ce5c447993b2a7f5cc32764b091ccf55365f0c.tar craftbukkit-97ce5c447993b2a7f5cc32764b091ccf55365f0c.tar.gz craftbukkit-97ce5c447993b2a7f5cc32764b091ccf55365f0c.tar.lz craftbukkit-97ce5c447993b2a7f5cc32764b091ccf55365f0c.tar.xz craftbukkit-97ce5c447993b2a7f5cc32764b091ccf55365f0c.zip |
Implemented PlayerShearEntityEvent in EntityMushroomCow.
Due to the Vanilla client overzealously predicting things, shearing produces
client-side artifacts. See BUKKIT-611 for more information.
-rw-r--r-- | src/main/java/net/minecraft/server/EntityMushroomCow.java | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/main/java/net/minecraft/server/EntityMushroomCow.java b/src/main/java/net/minecraft/server/EntityMushroomCow.java new file mode 100644 index 00000000..e2322a87 --- /dev/null +++ b/src/main/java/net/minecraft/server/EntityMushroomCow.java @@ -0,0 +1,49 @@ +package net.minecraft.server; + +public class EntityMushroomCow extends EntityCow { + + public EntityMushroomCow(World world) { + super(world); + this.texture = "/mob/redcow.png"; + this.b(0.9F, 1.3F); + } + + public boolean b(EntityHuman entityhuman) { + ItemStack itemstack = entityhuman.inventory.getItemInHand(); + + if (itemstack != null && itemstack.id == Item.BOWL.id && this.getAge() >= 0) { + entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, new ItemStack(Item.MUSHROOM_SOUP)); + return true; + } else if (itemstack != null && itemstack.id == Item.SHEARS.id && this.getAge() >= 0) { + // CraftBukkit start + org.bukkit.event.player.PlayerShearEntityEvent event = new org.bukkit.event.player.PlayerShearEntityEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), this.getBukkitEntity()); + this.world.getServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { + return false; + } + // CraftBukkit end + + this.die(); + EntityCow entitycow = new EntityCow(this.world); + + entitycow.setPositionRotation(this.locX, this.locY, this.locZ, this.yaw, this.pitch); + entitycow.setHealth(this.getHealth()); + entitycow.V = this.V; + this.world.addEntity(entitycow); + this.world.a("largeexplode", this.locX, this.locY + (double) (this.length / 2.0F), this.locZ, 0.0D, 0.0D, 0.0D); + + for (int i = 0; i < 5; ++i) { + this.world.addEntity(new EntityItem(this.world, this.locX, this.locY + (double) this.length, this.locZ, new ItemStack(Block.RED_MUSHROOM))); + } + + return true; + } else { + return super.b(entityhuman); + } + } + + protected EntityAnimal createChild(EntityAnimal entityanimal) { + return new EntityMushroomCow(this.world); + } +} |