package tasteslikebleach.tcm.items; import java.util.List; import java.util.Set; import com.google.common.collect.Sets; import net.minecraft.block.Block; import net.minecraft.block.BlockCrops; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemTool; import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.TextFormatting; import net.minecraft.world.World; import net.minecraftforge.common.util.EnumHelper; import tasteslikebleach.tcm.Reference; import tasteslikebleach.tcm.init.ModBlocks; import tasteslikebleach.tcm.init.ModItems; import tasteslikebleach.tcm.util.BetterRandom; import tasteslikebleach.tcm.util.Util; public class ItemPruningShears extends ItemTool { private static final Set EFFECTIVE_BLOCKS = Sets.newHashSet(new Block[] {}); public ItemPruningShears(String unlocalizedName) { super(EnumHelper.addToolMaterial(Reference.MODID + ":pruningshears", 0, 600, 3F, 1, 10) , EFFECTIVE_BLOCKS); this.setUnlocalizedName(unlocalizedName); this.setRegistryName(new ResourceLocation(Reference.MODID, unlocalizedName)); } @Override public void addInformation(ItemStack stack, World playerIn, List tooltip, ITooltipFlag flagIn) { super.addInformation(stack, playerIn, tooltip, flagIn); tooltip.add(TextFormatting.AQUA + Util.getLang().localize("pruningshears.tooltip")); } @Override public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ){ BetterRandom i = new BetterRandom(true); if(worldIn.getBlockState(pos) == ModBlocks.bananafruit.getDefaultState().withProperty(BlockCrops.AGE, 4)){ worldIn.setBlockState(pos, ModBlocks.bananafruit.getDefaultState()); EntityItem item = new EntityItem(player.getEntityWorld(), pos.getX(), pos.getY(), pos.getZ(), new ItemStack(ModItems.banana, i.spin3())); if(worldIn.isRemote != true){ worldIn.spawnEntity(item);} player.getHeldItemMainhand().damageItem(1, player); } if(worldIn.getBlockState(pos) == ModBlocks.blueberrybush.getDefaultState().withProperty(BlockCrops.AGE, 4)){ worldIn.setBlockState(pos, ModBlocks.blueberrybush.getDefaultState().withProperty(BlockCrops.AGE, 2)); EntityItem item = new EntityItem(player.getEntityWorld(), pos.getX(), pos.getY(), pos.getZ(), new ItemStack(ModItems.blueberry, i.spin3())); if(worldIn.isRemote != true){ worldIn.spawnEntity(item);} player.getHeldItemMainhand().damageItem(1, player); } if(worldIn.getBlockState(pos) == ModBlocks.corncrop.getDefaultState().withProperty(BlockCrops.AGE, 7)){ worldIn.setBlockState(pos, ModBlocks.corncrop.getDefaultState()); EntityItem item = new EntityItem(player.getEntityWorld(), pos.getX(), pos.getY(), pos.getZ(), new ItemStack(ModItems.corn, i.spin3())); if(worldIn.isRemote != true){ worldIn.spawnEntity(item);} player.getHeldItemMainhand().damageItem(1, player); } if(worldIn.getBlockState(pos) == Blocks.WHEAT.getDefaultState().withProperty(BlockCrops.AGE, 7)){ worldIn.setBlockState(pos, Blocks.WHEAT.getDefaultState().withProperty(BlockCrops.AGE, 1)); EntityItem item = new EntityItem(player.getEntityWorld(), pos.getX(), pos.getY(), pos.getZ(), new ItemStack(Items.WHEAT, i.spin3())); if(worldIn.isRemote != true){ worldIn.spawnEntity(item);} player.getHeldItemMainhand().damageItem(1, player); } if(worldIn.getBlockState(pos) == Blocks.NETHER_WART.getDefaultState().withProperty(BlockCrops.AGE, 7)){ worldIn.setBlockState(pos, Blocks.NETHER_WART.getDefaultState().withProperty(BlockCrops.AGE, 1)); EntityItem item = new EntityItem(player.getEntityWorld(), pos.getX(), pos.getY(), pos.getZ(), new ItemStack(Items.NETHER_WART, i.spin3())); if(worldIn.isRemote != true){ worldIn.spawnEntity(item);} player.getHeldItemMainhand().damageItem(1, player); } return null; } }