Search in sources :

Example 36 with ItemSword

use of net.minecraft.item.ItemSword in project kull by Sxmurai.

the class ItemInWorldManager method tryHarvestBlock.

/**
 * Attempts to harvest a block
 */
public boolean tryHarvestBlock(BlockPos pos) {
    if (this.gameType.isCreative() && this.thisPlayerMP.getHeldItem() != null && this.thisPlayerMP.getHeldItem().getItem() instanceof ItemSword) {
        return false;
    } else {
        IBlockState iblockstate = this.theWorld.getBlockState(pos);
        TileEntity tileentity = this.theWorld.getTileEntity(pos);
        if (this.gameType.isAdventure()) {
            if (this.gameType == WorldSettings.GameType.SPECTATOR) {
                return false;
            }
            if (!this.thisPlayerMP.isAllowEdit()) {
                ItemStack itemstack = this.thisPlayerMP.getCurrentEquippedItem();
                if (itemstack == null) {
                    return false;
                }
                if (!itemstack.canDestroy(iblockstate.getBlock())) {
                    return false;
                }
            }
        }
        this.theWorld.playAuxSFXAtEntity(this.thisPlayerMP, 2001, pos, Block.getStateId(iblockstate));
        boolean flag1 = this.removeBlock(pos);
        if (this.isCreative()) {
            this.thisPlayerMP.playerNetServerHandler.sendPacket(new S23PacketBlockChange(this.theWorld, pos));
        } else {
            ItemStack itemstack1 = this.thisPlayerMP.getCurrentEquippedItem();
            boolean flag = this.thisPlayerMP.canHarvestBlock(iblockstate.getBlock());
            if (itemstack1 != null) {
                itemstack1.onBlockDestroyed(this.theWorld, iblockstate.getBlock(), pos, this.thisPlayerMP);
                if (itemstack1.stackSize == 0) {
                    this.thisPlayerMP.destroyCurrentEquippedItem();
                }
            }
            if (flag1 && flag) {
                iblockstate.getBlock().harvestBlock(this.theWorld, this.thisPlayerMP, pos, iblockstate, tileentity);
            }
        }
        return flag1;
    }
}
Also used : ItemSword(net.minecraft.item.ItemSword) TileEntity(net.minecraft.tileentity.TileEntity) S23PacketBlockChange(net.minecraft.network.play.server.S23PacketBlockChange) IBlockState(net.minecraft.block.state.IBlockState) ItemStack(net.minecraft.item.ItemStack)

Example 37 with ItemSword

use of net.minecraft.item.ItemSword in project UtilityClient2 by Utility-Client.

the class PlayerControllerMP method onPlayerDestroyBlock.

/**
 * Called when a player completes the destruction of a block
 */
public boolean onPlayerDestroyBlock(BlockPos pos, EnumFacing side) {
    if (this.currentGameType.isAdventure()) {
        if (this.currentGameType == WorldSettings.GameType.SPECTATOR) {
            return false;
        }
        if (!this.mc.thePlayer.isAllowEdit()) {
            Block block = this.mc.theWorld.getBlockState(pos).getBlock();
            ItemStack itemstack = this.mc.thePlayer.getCurrentEquippedItem();
            if (itemstack == null) {
                return false;
            }
            if (!itemstack.canDestroy(block)) {
                return false;
            }
        }
    }
    if (this.currentGameType.isCreative() && this.mc.thePlayer.getHeldItem() != null && this.mc.thePlayer.getHeldItem().getItem() instanceof ItemSword) {
        return false;
    } else {
        World world = this.mc.theWorld;
        IBlockState iblockstate = world.getBlockState(pos);
        Block block1 = iblockstate.getBlock();
        if (block1.getMaterial() == Material.air) {
            return false;
        } else {
            world.playAuxSFX(2001, pos, Block.getStateId(iblockstate));
            boolean flag = world.setBlockToAir(pos);
            if (flag) {
                block1.onBlockDestroyedByPlayer(world, pos, iblockstate);
            }
            this.currentBlock = new BlockPos(this.currentBlock.getX(), -1, this.currentBlock.getZ());
            if (!this.currentGameType.isCreative()) {
                ItemStack itemstack1 = this.mc.thePlayer.getCurrentEquippedItem();
                if (itemstack1 != null) {
                    itemstack1.onBlockDestroyed(world, block1, pos, this.mc.thePlayer);
                    if (itemstack1.stackSize == 0) {
                        this.mc.thePlayer.destroyCurrentEquippedItem();
                    }
                }
            }
            return flag;
        }
    }
}
Also used : ItemSword(net.minecraft.item.ItemSword) IBlockState(net.minecraft.block.state.IBlockState) Block(net.minecraft.block.Block) ItemBlock(net.minecraft.item.ItemBlock) ItemStack(net.minecraft.item.ItemStack) World(net.minecraft.world.World)

Example 38 with ItemSword

use of net.minecraft.item.ItemSword in project UtilityClient2 by Utility-Client.

the class ItemInWorldManager method tryHarvestBlock.

/**
 * Attempts to harvest a block
 */
public boolean tryHarvestBlock(BlockPos pos) {
    if (this.gameType.isCreative() && this.thisPlayerMP.getHeldItem() != null && this.thisPlayerMP.getHeldItem().getItem() instanceof ItemSword) {
        return false;
    } else {
        IBlockState iblockstate = this.theWorld.getBlockState(pos);
        TileEntity tileentity = this.theWorld.getTileEntity(pos);
        if (this.gameType.isAdventure()) {
            if (this.gameType == WorldSettings.GameType.SPECTATOR) {
                return false;
            }
            if (!this.thisPlayerMP.isAllowEdit()) {
                ItemStack itemstack = this.thisPlayerMP.getCurrentEquippedItem();
                if (itemstack == null) {
                    return false;
                }
                if (!itemstack.canDestroy(iblockstate.getBlock())) {
                    return false;
                }
            }
        }
        this.theWorld.playAuxSFXAtEntity(this.thisPlayerMP, 2001, pos, Block.getStateId(iblockstate));
        boolean flag1 = this.removeBlock(pos);
        if (this.isCreative()) {
            this.thisPlayerMP.playerNetServerHandler.sendPacket(new S23PacketBlockChange(this.theWorld, pos));
        } else {
            ItemStack itemstack1 = this.thisPlayerMP.getCurrentEquippedItem();
            boolean flag = this.thisPlayerMP.canHarvestBlock(iblockstate.getBlock());
            if (itemstack1 != null) {
                itemstack1.onBlockDestroyed(this.theWorld, iblockstate.getBlock(), pos, this.thisPlayerMP);
                if (itemstack1.stackSize == 0) {
                    this.thisPlayerMP.destroyCurrentEquippedItem();
                }
            }
            if (flag1 && flag) {
                iblockstate.getBlock().harvestBlock(this.theWorld, this.thisPlayerMP, pos, iblockstate, tileentity);
            }
        }
        return flag1;
    }
}
Also used : ItemSword(net.minecraft.item.ItemSword) TileEntity(net.minecraft.tileentity.TileEntity) S23PacketBlockChange(net.minecraft.network.play.server.S23PacketBlockChange) IBlockState(net.minecraft.block.state.IBlockState) ItemStack(net.minecraft.item.ItemStack)

Example 39 with ItemSword

use of net.minecraft.item.ItemSword in project Almura by AlmuraDev.

the class MixinTileEntityFurnace method getItemBurnTime.

/**
 * @author Dockter - Mike Howe
 * @reason Add additional fuel blocks
 */
// TODO: migrate this to a targetted injection vs. Override.
@Overwrite
public static int getItemBurnTime(ItemStack stack) {
    if (stack.isEmpty()) {
        return 0;
    } else {
        Item item = stack.getItem();
        // Almura: additional blocks for fuel
        if (item == Item.getItemFromBlock(Blocks.MAGMA)) {
            return 12500;
        }
        Block charcoalBlock = Block.getBlockFromName("almura:horizontal/building/charcoalblock");
        if (charcoalBlock != null && item == Item.getItemFromBlock(charcoalBlock)) {
            return 10000;
        }
        if (item.getTranslationKey().length() > 19 && item.getTranslationKey().substring(5, 19).equalsIgnoreCase("almura.sapling")) {
            // tile.almura.sapling
            return 200;
        }
        if (item == Item.getItemFromBlock(Blocks.WOODEN_SLAB)) {
            return 150;
        } else if (item == Item.getItemFromBlock(Blocks.WOOL)) {
            return 100;
        } else if (item == Item.getItemFromBlock(Blocks.CARPET)) {
            return 67;
        } else if (item == Item.getItemFromBlock(Blocks.LADDER)) {
            return 300;
        } else if (item == Item.getItemFromBlock(Blocks.WOODEN_BUTTON)) {
            return 100;
        } else if (Block.getBlockFromItem(item).getDefaultState().getMaterial() == Material.WOOD) {
            return 300;
        } else if (item == Item.getItemFromBlock(Blocks.COAL_BLOCK)) {
            return 16000;
        } else if (item instanceof ItemTool && "WOOD".equals(((ItemTool) item).getToolMaterialName())) {
            return 200;
        } else if (item instanceof ItemSword && "WOOD".equals(((ItemSword) item).getToolMaterialName())) {
            return 200;
        } else if (item instanceof ItemHoe && "WOOD".equals(((ItemHoe) item).getMaterialName())) {
            return 200;
        } else if (item == Items.STICK) {
            return 100;
        } else if (item != Items.BOW && item != Items.FISHING_ROD) {
            if (item == Items.SIGN) {
                return 200;
            } else if (item == Items.COAL) {
                return 1600;
            } else if (item == Items.LAVA_BUCKET) {
                return 20000;
            } else if (item != Item.getItemFromBlock(Blocks.SAPLING) && item != Items.BOWL) {
                if (item == Items.BLAZE_ROD) {
                    return 2400;
                } else if (item instanceof ItemDoor && item != Items.IRON_DOOR) {
                    return 200;
                } else {
                    return item instanceof ItemBoat ? 400 : 0;
                }
            } else {
                return 100;
            }
        } else {
            return 300;
        }
    }
}
Also used : ItemSword(net.minecraft.item.ItemSword) Item(net.minecraft.item.Item) ItemHoe(net.minecraft.item.ItemHoe) ItemTool(net.minecraft.item.ItemTool) ItemBoat(net.minecraft.item.ItemBoat) ItemDoor(net.minecraft.item.ItemDoor) Block(net.minecraft.block.Block) Overwrite(org.spongepowered.asm.mixin.Overwrite)

Example 40 with ItemSword

use of net.minecraft.item.ItemSword 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)

Aggregations

ItemSword (net.minecraft.item.ItemSword)76 ItemStack (net.minecraft.item.ItemStack)53 Item (net.minecraft.item.Item)25 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)23 EntityPlayer (net.minecraft.entity.player.EntityPlayer)22 ItemTool (net.minecraft.item.ItemTool)21 ItemHoe (net.minecraft.item.ItemHoe)18 IBlockState (net.minecraft.block.state.IBlockState)17 ItemBow (net.minecraft.item.ItemBow)15 Entity (net.minecraft.entity.Entity)13 Block (net.minecraft.block.Block)9 EntityLivingBase (net.minecraft.entity.EntityLivingBase)8 ItemAxe (net.minecraft.item.ItemAxe)8 ItemBlock (net.minecraft.item.ItemBlock)8 World (net.minecraft.world.World)7 ItemArmor (net.minecraft.item.ItemArmor)6 ItemFishingRod (net.minecraft.item.ItemFishingRod)6 DamageSource (net.minecraft.util.DamageSource)6 ItemDoor (net.minecraft.item.ItemDoor)5 ItemShield (net.minecraft.item.ItemShield)5