use of net.minecraft.item.ItemHoe in project ConvenientAdditions by Necr0.
the class BlockCompostSoil method onBlockActivated.
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
ItemStack current = player.inventory.getStackInSlot(player.inventory.currentItem);
if (current == null || !(current.getItem() instanceof ItemHoe))
return false;
BlockPos posU = new BlockPos(pos.getX(), pos.getY() + 1, pos.getZ());
IBlockState stateU = world.getBlockState(posU);
if (stateU.getBlock().isAir(stateU, world, posU)) {
if (!world.isRemote) {
current.damageItem(1, player);
world.setBlockState(pos, ModBlocks.compostSoilTilledBlock.getStateFromMeta(this.getMetaFromState(state)), 3);
}
world.playSound(null, pos, SoundEvents.ITEM_HOE_TILL, SoundCategory.BLOCKS, 1.0F, 1.0F);
}
return true;
}
use of net.minecraft.item.ItemHoe in project BetterWithAddons by DaedalusGame.
the class WheatHandler method breakSpeed.
@SubscribeEvent
public static void breakSpeed(PlayerEvent.BreakSpeed event) {
if (!InteractionWheat.DIG_UP_CROPS)
return;
if (toolMaterialField == null)
toolMaterialField = ReflectionHelper.findField(ItemHoe.class, "field_77843_a", "toolMaterial");
EntityPlayer player = event.getEntityPlayer();
if (player == null)
return;
IBlockState state = event.getState();
Block block = state.getBlock();
ItemStack tool = player.getHeldItemMainhand();
if (tool.getItem() instanceof ItemHoe && "hoe".equals(block.getHarvestTool(state))) {
try {
Item.ToolMaterial material = (Item.ToolMaterial) toolMaterialField.get(tool.getItem());
if (material != null)
event.setNewSpeed(event.getNewSpeed() * material.getEfficiency());
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}
use of net.minecraft.item.ItemHoe in project Minechem by iopleke.
the class AugmentedItem method renderOverlay.
@Override
public void renderOverlay(FontRenderer fontRenderer, TextureManager textureManager, ItemStack itemStack, int left, int top, float z) {
RenderHelper.enableBlend();
RenderHelper.setOpacity(1.0F);
textureManager.bindTexture(TextureMap.locationItemsTexture);
ItemStack wrappedItemStack = getWrappedItemStack(itemStack);
if (wrappedItemStack != null) {
Item wrappedItem = wrappedItemStack.getItem();
if (wrappedItem instanceof ItemAxe) {
RenderHelper.drawTexturedRectUV(left, top, z + 10, 16, 16, augmentIcon[AXEICON]);
} else if (wrappedItem instanceof ItemHoe) {
RenderHelper.drawTexturedRectUV(left, top, z + 10, 16, 16, augmentIcon[HOEICON]);
} else if (wrappedItem instanceof ItemPickaxe) {
RenderHelper.drawTexturedRectUV(left, top, z + 10, 16, 16, augmentIcon[PICKICON]);
} else if (wrappedItem instanceof ItemSpade) {
RenderHelper.drawTexturedRectUV(left, top, z + 10, 16, 16, augmentIcon[SHOVELICON]);
} else if (wrappedItem instanceof ItemSword) {
RenderHelper.drawTexturedRectUV(left, top, z + 10, 16, 16, augmentIcon[SWORDICON]);
} else {
RenderHelper.drawTexturedRectUV(left, top, z + 10, 16, 16, augmentIcon[DEFAULTICON]);
}
}
RenderHelper.resetOpacity();
RenderHelper.disableBlend();
}
use of net.minecraft.item.ItemHoe in project NetherEx by LogicTechCorp.
the class EventHandler method onPlayerRightClickBlock.
@SubscribeEvent
public static void onPlayerRightClickBlock(PlayerInteractEvent.RightClickBlock event) {
World world = event.getWorld();
BlockPos pos = event.getPos();
EntityPlayer player = event.getEntityPlayer();
ItemStack stack = event.getItemStack();
if (stack.getItem() == NetherExItems.TOOL_SHOVEL_BONE || ConfigHandler.block.netherrack.allowAllShovelsToFlatten && stack.getItem() instanceof ItemHoe) {
IBlockState state = world.getBlockState(pos);
Block block = state.getBlock();
if (block == Blocks.NETHERRACK || block == NetherExBlocks.BLOCK_NETHERRACK || block == NetherExBlocks.BLOCK_HYPHAE) {
for (EnumHand hand : EnumHand.values()) {
if (player.getHeldItem(hand).getItem() instanceof ItemSpade) {
player.swingArm(hand);
}
}
int meta = block == Blocks.NETHERRACK ? 0 : block == NetherExBlocks.BLOCK_HYPHAE ? 3 : NetherExBlocks.BLOCK_NETHERRACK.getMetaFromState(state) + 1;
world.playSound(player, pos, SoundEvents.ITEM_SHOVEL_FLATTEN, SoundCategory.BLOCKS, 1.0F, 1.0F);
world.setBlockState(pos, NetherExBlocks.BLOCK_NETHERRACK_PATH.getDefaultState().withProperty(BlockNetherrackPath.TYPE, BlockNetherrackPath.EnumType.fromMeta(meta)), 11);
stack.damageItem(1, player);
}
}
if (stack.getItem() == NetherExItems.TOOL_HOE_BONE || ConfigHandler.block.soulSand.allowAllHoesToTill && stack.getItem() instanceof ItemHoe) {
if (world.getBlockState(pos).getBlock() == Blocks.SOUL_SAND) {
for (EnumHand hand : EnumHand.values()) {
if (player.getHeldItem(hand).getItem() instanceof ItemHoe) {
player.swingArm(hand);
}
}
world.playSound(player, pos, SoundEvents.ITEM_HOE_TILL, SoundCategory.BLOCKS, 1.0F, 1.0F);
world.setBlockState(pos, NetherExBlocks.BLOCK_SAND_SOUL_TILLED.getDefaultState(), 11);
stack.damageItem(1, player);
}
}
}
Aggregations