Search in sources :

Example 16 with ItemBlock

use of net.minecraft.item.ItemBlock in project ArsMagica2 by Mithion.

the class TileEntityCalefactor method smeltItem.

public void smeltItem() {
    if (this.canSmelt()) {
        ItemStack var1 = FurnaceRecipes.smelting().getSmeltingResult(this.calefactorItemStacks[0]);
        ItemStack smeltStack = var1.copy();
        if (this.calefactorItemStacks[0].getItem() instanceof ItemFood || this.calefactorItemStacks[0].getItem() instanceof ItemBlock || this.calefactorItemStacks[0].getItem() == ItemsCommonProxy.itemOre) {
            if (PowerNodeRegistry.For(worldObj).checkPower(this, PowerTypes.DARK, getCookTickPowerCost()))
                if (PowerNodeRegistry.For(worldObj).checkPower(this, PowerTypes.NEUTRAL, getCookTickPowerCost()))
                    if (PowerNodeRegistry.For(worldObj).checkPower(this, PowerTypes.LIGHT, getCookTickPowerCost()))
                        smeltStack.stackSize++;
        }
        if (this.calefactorItemStacks[0].getItem() instanceof ItemFood) {
            if (smeltStack.stackSize == var1.stackSize && worldObj.rand.nextDouble() < 0.15f) {
                smeltStack.stackSize++;
            }
        }
        boolean doSmelt = true;
        if (doSmelt) {
            if (this.calefactorItemStacks[1] == null) {
                this.calefactorItemStacks[1] = smeltStack.copy();
            } else if (this.calefactorItemStacks[1].isItemEqual(smeltStack)) {
                calefactorItemStacks[1].stackSize += smeltStack.stackSize;
                if (calefactorItemStacks[1].stackSize > calefactorItemStacks[1].getMaxStackSize()) {
                    calefactorItemStacks[1].stackSize = calefactorItemStacks[1].getMaxStackSize();
                }
            }
            if (Math.random() <= 0.25) {
                if (calefactorItemStacks[5] == null) {
                    calefactorItemStacks[5] = new ItemStack(ItemsCommonProxy.itemOre, 1, ItemsCommonProxy.itemOre.META_VINTEUMDUST);
                } else {
                    calefactorItemStacks[5].stackSize++;
                    if (calefactorItemStacks[5].stackSize > calefactorItemStacks[5].getMaxStackSize()) {
                        calefactorItemStacks[5].stackSize = calefactorItemStacks[5].getMaxStackSize();
                    }
                }
            }
        }
        --this.calefactorItemStacks[0].stackSize;
        if (this.calefactorItemStacks[0].stackSize <= 0) {
            this.calefactorItemStacks[0] = null;
        }
    }
}
Also used : ItemFood(net.minecraft.item.ItemFood) ItemStack(net.minecraft.item.ItemStack) ItemBlock(net.minecraft.item.ItemBlock)

Example 17 with ItemBlock

use of net.minecraft.item.ItemBlock in project ArsMagica2 by Mithion.

the class Forge method ApplyFurnaceToBlockAtCoords.

private boolean ApplyFurnaceToBlockAtCoords(EntityLivingBase entity, World world, int x, int y, int z) {
    Block block = world.getBlock(x, y, z);
    if (block == Blocks.air) {
        return false;
    }
    if (block == Blocks.ice) {
        if (!world.isRemote) {
            world.setBlock(x, y, z, Blocks.water);
        }
        return true;
    }
    int meta = world.getBlockMetadata(x, y, z);
    ItemStack smelted = FurnaceRecipes.smelting().getSmeltingResult(new ItemStack(block, 1, meta));
    if (smelted == null) {
        return false;
    }
    if (!world.isRemote) {
        if (ItemIsBlock(smelted.getItem())) {
            world.setBlock(x, y, z, ((ItemBlock) smelted.getItem()).field_150939_a);
        } else {
            entity.entityDropItem(new ItemStack(smelted.getItem(), 1, smelted.getItemDamage()), 0);
            world.setBlock(x, y, z, Blocks.air);
        }
    }
    return true;
}
Also used : Block(net.minecraft.block.Block) ItemBlock(net.minecraft.item.ItemBlock) ItemStack(net.minecraft.item.ItemStack)

Example 18 with ItemBlock

use of net.minecraft.item.ItemBlock in project minecolonies by Minecolonies.

the class AbstractBlockHut method initBlock.

/**
     * Initiates the basic block variables.
     */
private void initBlock() {
    setRegistryName(getName());
    setUnlocalizedName(Constants.MOD_ID.toLowerCase() + "." + getName());
    setCreativeTab(ModCreativeTabs.MINECOLONIES);
    //Blast resistance for creepers etc. makes them explosion proof
    setResistance(RESISTANCE);
    //Hardness of 10 takes a long time to mine to not loose progress
    setHardness(HARDNESS);
    this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));
    GameRegistry.register(this);
    GameRegistry.register((new ItemBlock(this)).setRegistryName(this.getRegistryName()));
}
Also used : ItemBlock(net.minecraft.item.ItemBlock)

Example 19 with ItemBlock

use of net.minecraft.item.ItemBlock in project minecolonies by Minecolonies.

the class BlockConstructionTape method initBlock.

/**
     * initialize the block
     * sets the creative tab, as well as the resistance and the hardness.
     */
private void initBlock() {
    setRegistryName(BLOCK_NAME);
    setUnlocalizedName(String.format("%s.%s", Constants.MOD_ID.toLowerCase(), BLOCK_NAME));
    setCreativeTab(ModCreativeTabs.MINECOLONIES);
    GameRegistry.register(this);
    GameRegistry.register((new ItemBlock(this)).setRegistryName(this.getRegistryName()));
    this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));
    setHardness(BLOCK_HARDNESS);
    setResistance(RESISTANCE);
    setLightOpacity(LIGHT_OPACITY);
}
Also used : ItemBlock(net.minecraft.item.ItemBlock)

Example 20 with ItemBlock

use of net.minecraft.item.ItemBlock in project minecolonies by Minecolonies.

the class BlockConstructionTapeCorner method initBlock.

/**
     * initialize the block
     * sets the creative tab, as well as the resistance and the hardness.
     */
private void initBlock() {
    setRegistryName(BLOCK_NAME);
    setUnlocalizedName(String.format("%s.%s", Constants.MOD_ID.toLowerCase(), BLOCK_NAME));
    setCreativeTab(ModCreativeTabs.MINECOLONIES);
    GameRegistry.register(this);
    GameRegistry.register((new ItemBlock(this)).setRegistryName(this.getRegistryName()));
    this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));
    setHardness(BLOCK_HARDNESS);
    setResistance(RESISTANCE);
    setLightOpacity(LIGHT_OPACITY);
}
Also used : ItemBlock(net.minecraft.item.ItemBlock)

Aggregations

ItemBlock (net.minecraft.item.ItemBlock)69 Block (net.minecraft.block.Block)36 ItemStack (net.minecraft.item.ItemStack)34 Item (net.minecraft.item.Item)14 IBlockState (net.minecraft.block.state.IBlockState)7 EntityItem (net.minecraft.entity.item.EntityItem)4 TileEntity (net.minecraft.tileentity.TileEntity)4 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)3 RenderItem (net.minecraft.client.renderer.entity.RenderItem)3 EnumFacing (net.minecraft.util.EnumFacing)3 BlockPos (net.minecraft.util.math.BlockPos)3 AMVector3 (am2.api.math.AMVector3)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 CustomizableSCTE (net.geforcemods.securitycraft.api.CustomizableSCTE)2 IExplosive (net.geforcemods.securitycraft.api.IExplosive)2 IOwnable (net.geforcemods.securitycraft.api.IOwnable)2 Tessellator (net.minecraft.client.renderer.Tessellator)2 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 ChatComponentText (net.minecraft.util.ChatComponentText)2