Search in sources :

Example 1 with ItemSpade

use of net.minecraft.item.ItemSpade 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 2 with ItemSpade

use of net.minecraft.item.ItemSpade 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)2 ItemSpade (net.minecraft.item.ItemSpade)2 ItemStack (net.minecraft.item.ItemStack)2 WrapperItem (minechem.item.prefab.WrapperItem)1 Block (net.minecraft.block.Block)1 IBlockState (net.minecraft.block.state.IBlockState)1 EntityItem (net.minecraft.entity.item.EntityItem)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 Item (net.minecraft.item.Item)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 BlockPos (net.minecraft.util.math.BlockPos)1 World (net.minecraft.world.World)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1