Search in sources :

Example 1 with ItemHoe

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;
}
Also used : ItemHoe(net.minecraft.item.ItemHoe) IBlockState(net.minecraft.block.state.IBlockState) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack)

Example 2 with ItemHoe

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();
        }
    }
}
Also used : ItemHoe(net.minecraft.item.ItemHoe) EntityItem(net.minecraft.entity.item.EntityItem) Item(net.minecraft.item.Item) IBlockState(net.minecraft.block.state.IBlockState) EntityPlayer(net.minecraft.entity.player.EntityPlayer) Block(net.minecraft.block.Block) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 3 with ItemHoe

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();
}
Also used : ItemSword(net.minecraft.item.ItemSword) Item(net.minecraft.item.Item) EntityItem(net.minecraft.entity.item.EntityItem) WrapperItem(minechem.item.prefab.WrapperItem) ItemAxe(net.minecraft.item.ItemAxe) ItemHoe(net.minecraft.item.ItemHoe) ItemSpade(net.minecraft.item.ItemSpade) ItemPickaxe(net.minecraft.item.ItemPickaxe) ItemStack(net.minecraft.item.ItemStack)

Example 4 with ItemHoe

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);
        }
    }
}
Also used : ItemHoe(net.minecraft.item.ItemHoe) IBlockState(net.minecraft.block.state.IBlockState) ItemSpade(net.minecraft.item.ItemSpade) EnumHand(net.minecraft.util.EnumHand) EntityPlayer(net.minecraft.entity.player.EntityPlayer) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

ItemHoe (net.minecraft.item.ItemHoe)4 ItemStack (net.minecraft.item.ItemStack)4 IBlockState (net.minecraft.block.state.IBlockState)3 Block (net.minecraft.block.Block)2 EntityItem (net.minecraft.entity.item.EntityItem)2 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 Item (net.minecraft.item.Item)2 ItemSpade (net.minecraft.item.ItemSpade)2 BlockPos (net.minecraft.util.math.BlockPos)2 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)2 WrapperItem (minechem.item.prefab.WrapperItem)1 ItemAxe (net.minecraft.item.ItemAxe)1 ItemPickaxe (net.minecraft.item.ItemPickaxe)1 ItemSword (net.minecraft.item.ItemSword)1 EnumHand (net.minecraft.util.EnumHand)1 World (net.minecraft.world.World)1