Guest User

Untitled

a guest
Jul 23rd, 2017
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.40 KB | None | 0 0
  1. package com.TheRPGAdventurer.client.items;
  2.  
  3. import com.TheRPGAdventurer.RealmOfTheDragons;
  4. import com.TheRPGAdventurer.server.entity.EntityTameableDragon;
  5.  
  6. import net.minecraft.creativetab.CreativeTabs;
  7. import net.minecraft.entity.EntityLivingBase;
  8. import net.minecraft.entity.player.EntityPlayer;
  9. import net.minecraft.item.ItemShears;
  10. import net.minecraft.item.ItemStack;
  11. import net.minecraft.util.ResourceLocation;
  12. import net.minecraft.util.math.BlockPos;
  13. import net.minecraftforge.common.IShearable;
  14.  
  15. public class ItemDiamondShears extends ItemShears {
  16.  
  17. public ItemDiamondShears(String unlocalizedName, String registryName) {
  18. this.setUnlocalizedName(unlocalizedName);
  19. this.setRegistryName(new ResourceLocation(registryName));
  20. this.setMaxDamage(345);
  21. this.setMaxStackSize(1);
  22. this.setCreativeTab(CreativeTabs.TOOLS);
  23. }
  24.  
  25. @Override
  26. public boolean itemInteractionForEntity(ItemStack itemstack, EntityPlayer player, EntityLivingBase entity, net.minecraft.util.EnumHand hand) {
  27. if (entity.worldObj.isRemote)
  28. {return false;}
  29. if (entity instanceof EntityTameableDragon)
  30. {
  31. EntityTameableDragon target = (EntityTameableDragon)entity;
  32. BlockPos pos = new BlockPos(entity.posX, entity.posY, entity.posZ);
  33. if (target.isShearable(itemstack, entity.worldObj, pos))
  34. {
  35. java.util.List<ItemStack> drops = target.onSheared(itemstack, entity.worldObj, pos,
  36. net.minecraft.enchantment.EnchantmentHelper.getEnchantmentLevel(net.minecraft.init.Enchantments.FORTUNE, itemstack));
  37.  
  38. java.util.Random rand = new java.util.Random();
  39. for(ItemStack stack : drops)
  40. {
  41. net.minecraft.entity.item.EntityItem ent = entity.entityDropItem(stack, 1.0F);
  42. ent.motionY += rand.nextFloat() * 0.05F;
  43. ent.motionX += (rand.nextFloat() - rand.nextFloat()) * 0.1F;
  44. ent.motionZ += (rand.nextFloat() - rand.nextFloat()) * 0.1F;
  45. }
  46. itemstack.damageItem(154, entity);
  47. }
  48.  
  49. return true;
  50.  
  51. } else {
  52.  
  53. if (entity.worldObj.isRemote)
  54. {return false;}
  55. if (entity instanceof IShearable)
  56. {
  57. IShearable target = (IShearable)entity;
  58. BlockPos pos = new BlockPos(entity.posX, entity.posY, entity.posZ);
  59. if (target.isShearable(itemstack, entity.worldObj, pos))
  60. {
  61. java.util.List<ItemStack> drops = target.onSheared(itemstack, entity.worldObj, pos,
  62. net.minecraft.enchantment.EnchantmentHelper.getEnchantmentLevel(net.minecraft.init.Enchantments.FORTUNE, itemstack));
  63.  
  64. java.util.Random rand = new java.util.Random();
  65. for(ItemStack stack : drops)
  66. {
  67. net.minecraft.entity.item.EntityItem ent = entity.entityDropItem(stack, 1.0F);
  68. ent.motionY += rand.nextFloat() * 0.05F;
  69. ent.motionX += (rand.nextFloat() - rand.nextFloat()) * 0.1F;
  70. ent.motionZ += (rand.nextFloat() - rand.nextFloat()) * 0.1F;
  71. }
  72. itemstack.damageItem(1, entity);
  73. }
  74. return true;
  75. }
  76.  
  77. return false;
  78. }
  79.  
  80. }
  81.  
  82. }
Advertisement
Add Comment
Please, Sign In to add comment