87 lines
3.7 KiB
Diff
87 lines
3.7 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 i)
|
||
|
@@ -11,9 +15,8 @@
|
||
|
|
||
|
public boolean onBlockDestroyed(ItemStack itemstack, int i, int j, int k, int l, EntityLiving entityliving)
|
||
|
{
|
||
|
- if (i == Block.leaves.blockID || i == Block.web.blockID || i == Block.tallGrass.blockID || i == Block.vine.blockID)
|
||
|
+ if (i == Block.leaves.blockID || i == Block.web.blockID || i == Block.tallGrass.blockID || i == Block.vine.blockID || Block.blocksList[i] instanceof IShearable)
|
||
|
{
|
||
|
- itemstack.damageItem(1, entityliving);
|
||
|
return true;
|
||
|
}
|
||
|
else
|
||
|
@@ -42,4 +45,62 @@
|
||
|
return super.getStrVsBlock(itemstack, block);
|
||
|
}
|
||
|
}
|
||
|
+
|
||
|
+ @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;
|
||
|
+ }
|
||
|
}
|