Advertisement
TastesLikeBleach

ItemPruningShears.java

Nov 25th, 2017
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.18 KB | None | 0 0
  1. package tasteslikebleach.tcm.items;
  2.  
  3. import java.util.List;
  4. import java.util.Set;
  5.  
  6. import com.google.common.collect.Sets;
  7.  
  8. import net.minecraft.block.Block;
  9. import net.minecraft.block.BlockCrops;
  10. import net.minecraft.client.util.ITooltipFlag;
  11. import net.minecraft.entity.item.EntityItem;
  12. import net.minecraft.entity.player.EntityPlayer;
  13. import net.minecraft.init.Blocks;
  14. import net.minecraft.init.Items;
  15. import net.minecraft.item.ItemStack;
  16. import net.minecraft.item.ItemTool;
  17. import net.minecraft.util.EnumActionResult;
  18. import net.minecraft.util.EnumFacing;
  19. import net.minecraft.util.EnumHand;
  20. import net.minecraft.util.ResourceLocation;
  21. import net.minecraft.util.math.BlockPos;
  22. import net.minecraft.util.text.TextFormatting;
  23. import net.minecraft.world.World;
  24. import net.minecraftforge.common.util.EnumHelper;
  25. import tasteslikebleach.tcm.Reference;
  26. import tasteslikebleach.tcm.init.ModBlocks;
  27. import tasteslikebleach.tcm.init.ModItems;
  28. import tasteslikebleach.tcm.util.BetterRandom;
  29. import tasteslikebleach.tcm.util.Util;
  30.  
  31. public class ItemPruningShears extends ItemTool {
  32.    
  33.     private static final Set<Block> EFFECTIVE_BLOCKS = Sets.newHashSet(new Block[] {});
  34.  
  35.     public ItemPruningShears(String unlocalizedName) {
  36.         super(EnumHelper.addToolMaterial(Reference.MODID + ":pruningshears", 0, 600, 3F, 1, 10) , EFFECTIVE_BLOCKS);
  37.         this.setUnlocalizedName(unlocalizedName);
  38.         this.setRegistryName(new ResourceLocation(Reference.MODID, unlocalizedName));
  39.     }
  40. @Override
  41. public void addInformation(ItemStack stack, World playerIn, List<String> tooltip, ITooltipFlag flagIn) {
  42.     super.addInformation(stack, playerIn, tooltip, flagIn);
  43.     tooltip.add(TextFormatting.AQUA + Util.getLang().localize("pruningshears.tooltip"));
  44. }
  45. @Override
  46. public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ){
  47.     BetterRandom i = new BetterRandom(true);
  48.     if(worldIn.getBlockState(pos) == ModBlocks.bananafruit.getDefaultState().withProperty(BlockCrops.AGE, 4)){
  49.         worldIn.setBlockState(pos, ModBlocks.bananafruit.getDefaultState());
  50.         EntityItem item = new EntityItem(player.getEntityWorld(), pos.getX(), pos.getY(), pos.getZ(), new ItemStack(ModItems.banana, i.spin3()));
  51.         if(worldIn.isRemote != true){
  52.         worldIn.spawnEntity(item);}
  53.         player.getHeldItemMainhand().damageItem(1, player);
  54.     }
  55.     if(worldIn.getBlockState(pos) == ModBlocks.blueberrybush.getDefaultState().withProperty(BlockCrops.AGE, 4)){
  56.         worldIn.setBlockState(pos, ModBlocks.blueberrybush.getDefaultState().withProperty(BlockCrops.AGE, 2));
  57.         EntityItem item = new EntityItem(player.getEntityWorld(), pos.getX(), pos.getY(), pos.getZ(), new ItemStack(ModItems.blueberry, i.spin3()));
  58.         if(worldIn.isRemote != true){
  59.         worldIn.spawnEntity(item);}
  60.         player.getHeldItemMainhand().damageItem(1, player);
  61.     }
  62.     if(worldIn.getBlockState(pos) == ModBlocks.corncrop.getDefaultState().withProperty(BlockCrops.AGE, 7)){
  63.         worldIn.setBlockState(pos, ModBlocks.corncrop.getDefaultState());
  64.         EntityItem item = new EntityItem(player.getEntityWorld(), pos.getX(), pos.getY(), pos.getZ(), new ItemStack(ModItems.corn, i.spin3()));
  65.         if(worldIn.isRemote != true){
  66.         worldIn.spawnEntity(item);}
  67.         player.getHeldItemMainhand().damageItem(1, player);
  68.     }
  69.     if(worldIn.getBlockState(pos) == Blocks.WHEAT.getDefaultState().withProperty(BlockCrops.AGE, 7)){
  70.         worldIn.setBlockState(pos, Blocks.WHEAT.getDefaultState().withProperty(BlockCrops.AGE, 1));
  71.         EntityItem item = new EntityItem(player.getEntityWorld(), pos.getX(), pos.getY(), pos.getZ(), new ItemStack(Items.WHEAT, i.spin3()));
  72.         if(worldIn.isRemote != true){
  73.         worldIn.spawnEntity(item);}
  74.         player.getHeldItemMainhand().damageItem(1, player);
  75.     }
  76.     if(worldIn.getBlockState(pos) == Blocks.NETHER_WART.getDefaultState().withProperty(BlockCrops.AGE, 7)){
  77.         worldIn.setBlockState(pos, Blocks.NETHER_WART.getDefaultState().withProperty(BlockCrops.AGE, 1));
  78.         EntityItem item = new EntityItem(player.getEntityWorld(), pos.getX(), pos.getY(), pos.getZ(), new ItemStack(Items.NETHER_WART, i.spin3()));
  79.         if(worldIn.isRemote != true){
  80.         worldIn.spawnEntity(item);}
  81.         player.getHeldItemMainhand().damageItem(1, player);
  82.     }
  83.     return null;
  84.  
  85. }
  86.  
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement