90 lines
4.1 KiB
Diff
90 lines
4.1 KiB
Diff
--- ../src_base/minecraft_server/net/minecraft/src/ItemShears.java 0000-00-00 00:00:00.000000000 -0000
|
|
+++ ../src_work/minecraft_server/net/minecraft/src/ItemShears.java 0000-00-00 00:00:00.000000000 -0000
|
|
@@ -1,5 +1,9 @@
|
|
package net.minecraft.src;
|
|
|
|
+import java.util.ArrayList;
|
|
+
|
|
+import net.minecraft.src.forge.IShearable;
|
|
+
|
|
public class ItemShears extends Item
|
|
{
|
|
public ItemShears(int par1)
|
|
@@ -11,13 +15,12 @@
|
|
|
|
public boolean onBlockDestroyed(ItemStack par1ItemStack, int par2, int par3, int par4, int par5, EntityLiving par6EntityLiving)
|
|
{
|
|
- if (par2 != Block.leaves.blockID && par2 != Block.web.blockID && par2 != Block.tallGrass.blockID && par2 != Block.vine.blockID)
|
|
+ if (par2 != Block.leaves.blockID && par2 != Block.web.blockID && par2 != Block.tallGrass.blockID && par2 != Block.vine.blockID && !(Block.blocksList[par2] instanceof IShearable))
|
|
{
|
|
return super.onBlockDestroyed(par1ItemStack, par2, par3, par4, par5, par6EntityLiving);
|
|
}
|
|
else
|
|
{
|
|
- par1ItemStack.damageItem(1, par6EntityLiving);
|
|
return true;
|
|
}
|
|
}
|
|
@@ -38,4 +41,62 @@
|
|
{
|
|
return par2Block.blockID != Block.web.blockID && par2Block.blockID != Block.leaves.blockID ? (par2Block.blockID == Block.cloth.blockID ? 5.0F : super.getStrVsBlock(par1ItemStack, par2Block)) : 15.0F;
|
|
}
|
|
+
|
|
+ @Override
|
|
+ public void useItemOnEntity(ItemStack itemstack, EntityLiving entity)
|
|
+ {
|
|
+ if (entity.worldObj.isRemote)
|
|
+ {
|
|
+ return;
|
|
+ }
|
|
+ if (entity instanceof IShearable)
|
|
+ {
|
|
+ IShearable target = (IShearable)entity;
|
|
+ if (target.isShearable(itemstack, entity.worldObj, (int)entity.posX, (int)entity.posY, (int)entity.posZ))
|
|
+ {
|
|
+ ArrayList<ItemStack> drops = target.onSheared(itemstack, entity.worldObj, (int)entity.posX, (int)entity.posY, (int)entity.posZ,
|
|
+ EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, itemstack));
|
|
+ for(ItemStack stack : drops)
|
|
+ {
|
|
+ EntityItem ent = entity.entityDropItem(stack, 1.0F);
|
|
+ ent.motionY += entity.rand.nextFloat() * 0.05F;
|
|
+ ent.motionX += (entity.rand.nextFloat() - entity.rand.nextFloat()) * 0.1F;
|
|
+ ent.motionZ += (entity.rand.nextFloat() - entity.rand.nextFloat()) * 0.1F;
|
|
+ }
|
|
+ itemstack.damageItem(1, entity);
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public boolean onBlockStartBreak(ItemStack itemstack, int X, int Y, int Z, EntityPlayer player)
|
|
+ {
|
|
+ if (player.worldObj.isRemote)
|
|
+ {
|
|
+ return false;
|
|
+ }
|
|
+ int id = player.worldObj.getBlockId(X, Y, Z);
|
|
+ if (Block.blocksList[id] != null && Block.blocksList[id] instanceof IShearable)
|
|
+ {
|
|
+ IShearable target = (IShearable)Block.blocksList[id];
|
|
+ if (target.isShearable(itemstack, player.worldObj, X, Y, Z))
|
|
+ {
|
|
+ ArrayList<ItemStack> drops = target.onSheared(itemstack, player.worldObj, X, Y, Z,
|
|
+ EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, itemstack));
|
|
+ for(ItemStack stack : drops)
|
|
+ {
|
|
+ float f = 0.7F;
|
|
+ double d = (double)(player.rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D;
|
|
+ double d1 = (double)(player.rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D;
|
|
+ double d2 = (double)(player.rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D;
|
|
+ EntityItem entityitem = new EntityItem(player.worldObj, (double)X + d, (double)Y + d1, (double)Z + d2, stack);
|
|
+ entityitem.delayBeforeCanPickup = 10;
|
|
+ player.worldObj.spawnEntityInWorld(entityitem);
|
|
+ }
|
|
+ itemstack.damageItem(1, player);
|
|
+ player.addStat(StatList.mineBlockStatArray[id], 1);
|
|
+ }
|
|
+ }
|
|
+ return false;
|
|
+ }
|
|
}
|