ForgePatch/patches/minecraft/net/minecraft/src/EntitySheep.java.patch

68 lines
2.3 KiB
Diff

--- ../src_base/minecraft/net/minecraft/src/EntitySheep.java 0000-00-00 00:00:00.000000000 -0000
+++ ../src_work/minecraft/net/minecraft/src/EntitySheep.java 0000-00-00 00:00:00.000000000 -0000
@@ -1,8 +1,11 @@
package net.minecraft.src;
+import java.util.ArrayList;
import java.util.Random;
-public class EntitySheep extends EntityAnimal
+import net.minecraft.src.forge.IShearable;
+
+public class EntitySheep extends EntityAnimal implements IShearable
{
/**
* Holds the RGB table of the sheep colors - in OpenGL glColor3f values - used to render the sheep colored fleece.
@@ -129,27 +132,6 @@
*/
public boolean interact(EntityPlayer par1EntityPlayer)
{
- ItemStack var2 = par1EntityPlayer.inventory.getCurrentItem();
-
- if (var2 != null && var2.itemID == Item.shears.shiftedIndex && !this.getSheared() && !this.isChild())
- {
- if (!this.worldObj.isRemote)
- {
- this.setSheared(true);
- int var3 = 1 + this.rand.nextInt(3);
-
- for (int var4 = 0; var4 < var3; ++var4)
- {
- EntityItem var5 = this.entityDropItem(new ItemStack(Block.cloth.blockID, 1, this.getFleeceColor()), 1.0F);
- var5.motionY += (double)(this.rand.nextFloat() * 0.05F);
- var5.motionX += (double)((this.rand.nextFloat() - this.rand.nextFloat()) * 0.1F);
- var5.motionZ += (double)((this.rand.nextFloat() - this.rand.nextFloat()) * 0.1F);
- }
- }
-
- var2.damageItem(1, par1EntityPlayer);
- }
-
return super.interact(par1EntityPlayer);
}
@@ -282,4 +264,23 @@
this.setGrowingAge(var1);
}
}
+
+ @Override
+ public boolean isShearable(ItemStack item, World world, int X, int Y, int Z)
+ {
+ return !getSheared() && !isChild();
+ }
+
+ @Override
+ public ArrayList<ItemStack> onSheared(ItemStack item, World world, int X, int Y, int Z, int fortune)
+ {
+ ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
+ setSheared(true);
+ int i = 1 + rand.nextInt(3);
+ for (int j = 0; j < i; j++)
+ {
+ ret.add(new ItemStack(Block.cloth.blockID, 1, getFleeceColor()));
+ }
+ return ret;
+ }
}