Search in sources :

Example 46 with ItemBlock

use of net.minecraft.item.ItemBlock in project PneumaticCraft by MineMaarten.

the class BlockPneumaticDoorBase method getIcon.

@Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
    TileEntityPneumaticDoorBase te = (TileEntityPneumaticDoorBase) world.getTileEntity(x, y, z);
    ItemStack camoStack = te.getStackInSlot(TileEntityPneumaticDoorBase.CAMO_SLOT);
    if (camoStack != null && camoStack.getItem() instanceof ItemBlock) {
        Block block = ((ItemBlock) camoStack.getItem()).field_150939_a;
        if (PneumaticCraftUtils.isRenderIDCamo(block.getRenderType())) {
            return block.getIcon(side, camoStack.getItemDamage());
        }
    }
    return this.getIcon(side, world.getBlockMetadata(x, y, z));
}
Also used : TileEntityPneumaticDoorBase(pneumaticCraft.common.tileentity.TileEntityPneumaticDoorBase) Block(net.minecraft.block.Block) ItemBlock(net.minecraft.item.ItemBlock) ItemStack(net.minecraft.item.ItemStack) ItemBlock(net.minecraft.item.ItemBlock)

Example 47 with ItemBlock

use of net.minecraft.item.ItemBlock in project PneumaticCraft by MineMaarten.

the class TileEntityElevatorBase method onDescUpdate.

@Override
public void onDescUpdate() {
    baseCamo = inventory[4] != null && inventory[4].getItem() instanceof ItemBlock ? ((ItemBlock) inventory[4].getItem()).field_150939_a : null;
    Block newFrameCamo = inventory[5] != null && inventory[5].getItem() instanceof ItemBlock ? ((ItemBlock) inventory[5].getItem()).field_150939_a : null;
    if (newFrameCamo != frameCamo) {
        frameCamo = newFrameCamo;
        rerenderChunk();
    }
}
Also used : Block(net.minecraft.block.Block) ItemBlock(net.minecraft.item.ItemBlock) ItemBlock(net.minecraft.item.ItemBlock)

Example 48 with ItemBlock

use of net.minecraft.item.ItemBlock in project MinecraftForge by MinecraftForge.

the class DynBucketTest method preInit.

@SuppressWarnings("unused")
@EventHandler
public void preInit(FMLPreInitializationEvent event) {
    if (!ENABLE || !ModelFluidDebug.ENABLE)
        return;
    GameRegistry.register(new TestItem(), testItemName);
    Block tank = new BlockSimpleTank();
    GameRegistry.register(tank, simpleTankName);
    GameRegistry.register(new ItemBlock(tank), simpleTankName);
    GameRegistry.registerTileEntity(TileSimpleTank.class, "simpletank");
    FluidRegistry.addBucketForFluid(FluidRegistry.getFluid(TestFluid.name));
    FluidRegistry.addBucketForFluid(FluidRegistry.getFluid(TestGas.name));
    //GameRegistry.registerItem(dynBucket, "dynbucket");
    GameRegistry.register(dynBottle);
    ItemStack filledBucket = UniversalBucket.getFilledBucket(ForgeModContainer.getInstance().universalBucket, TestFluid.instance);
    GameRegistry.addShapelessRecipe(new ItemStack(Items.DIAMOND), filledBucket);
    proxy.setupModels();
//MinecraftForge.EVENT_BUS.register(this);
}
Also used : Block(net.minecraft.block.Block) IFluidBlock(net.minecraftforge.fluids.IFluidBlock) ItemBlock(net.minecraft.item.ItemBlock) ItemBlock(net.minecraft.item.ItemBlock) ItemStack(net.minecraft.item.ItemStack) EventHandler(net.minecraftforge.fml.common.Mod.EventHandler)

Example 49 with ItemBlock

use of net.minecraft.item.ItemBlock in project MinecraftForge by MinecraftForge.

the class ModelLoaderRegistryDebug method preInit.

@EventHandler
public void preInit(FMLPreInitializationEvent event) {
    List<Block> blocks = Lists.newArrayList();
    blocks.add(CustomModelBlock.instance);
    blocks.add(OBJTesseractBlock.instance);
    blocks.add(OBJVertexColoring1.instance);
    //blocks.add(OBJDirectionEye.instance);
    blocks.add(OBJVertexColoring2.instance);
    blocks.add(OBJDirectionBlock.instance);
    blocks.add(OBJCustomDataBlock.instance);
    //blocks.add(OBJDynamicEye.instance);
    for (Block block : blocks) {
        GameRegistry.register(block);
        GameRegistry.register(new ItemBlock(block).setRegistryName(block.getRegistryName()));
    }
    GameRegistry.registerTileEntity(OBJTesseractTileEntity.class, OBJTesseractBlock.name);
    GameRegistry.registerTileEntity(OBJVertexColoring2TileEntity.class, OBJVertexColoring2.name);
    //GameRegistry.registerTileEntity(OBJDynamicEyeTileEntity.class, OBJDynamicEye.name);
    if (event.getSide() == Side.CLIENT)
        clientPreInit();
}
Also used : Block(net.minecraft.block.Block) ItemBlock(net.minecraft.item.ItemBlock) ItemBlock(net.minecraft.item.ItemBlock) EventHandler(net.minecraftforge.fml.common.Mod.EventHandler)

Example 50 with ItemBlock

use of net.minecraft.item.ItemBlock in project MinecraftForge by MinecraftForge.

the class ItemBlockSubstitutionRemoveRestoreTest method testSubstitutionRemovalAndRestore.

@Test
public void testSubstitutionRemovalAndRestore() throws Exception {
    GameRegistry.addSubstitutionAlias("minecraft:dirt", GameRegistry.Type.ITEM, myDirtInstance);
    PersistentRegistryManager.freezeData();
    ObjectHolderRegistry.INSTANCE.applyObjectHolders();
    final FMLControlledNamespacedRegistry<Item> itemRegistry = (FMLControlledNamespacedRegistry<Item>) PersistentRegistryManager.findRegistryByType(Item.class);
    // TEST 1: Does my substitute take effect? The substitute should be found in the registry
    ItemBlock dirtitem = (ItemBlock) itemRegistry.getValue(myDirt);
    assertEquals("ItemBlock points at my block", myDirtInstance, dirtitem);
    // TEST 2: Does the substitute get removed when told by remote operation? The substitute should NOT be found in the registry
    final PersistentRegistryManager.GameDataSnapshot snapshot = PersistentRegistryManager.takeSnapshot();
    snapshot.entries.get(PersistentRegistryManager.ITEMS).substitutions.clear();
    PersistentRegistryManager.injectSnapshot(snapshot, false, false);
    ObjectHolderRegistry.INSTANCE.applyObjectHolders();
    dirtitem = (ItemBlock) itemRegistry.getValue(myDirt);
    assertEquals("ItemBlock points at vanilla block", originalDirt, dirtitem);
    assertNotEquals("ItemBlock points at my block", myDirtInstance, dirtitem);
    // TEST 3: Does the substitute get restored when reverting to frozen state? The substitute should be found in the registry again
    PersistentRegistryManager.revertToFrozen();
    ObjectHolderRegistry.INSTANCE.applyObjectHolders();
    dirtitem = (ItemBlock) itemRegistry.getValue(myDirt);
    assertEquals("ItemBlock points at my block", myDirtInstance, dirtitem);
}
Also used : Item(net.minecraft.item.Item) ItemBlock(net.minecraft.item.ItemBlock) Test(org.junit.Test)

Aggregations

ItemBlock (net.minecraft.item.ItemBlock)78 Block (net.minecraft.block.Block)41 ItemStack (net.minecraft.item.ItemStack)37 Item (net.minecraft.item.Item)20 IBlockState (net.minecraft.block.state.IBlockState)11 EntityItem (net.minecraft.entity.item.EntityItem)4 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)4 TileEntity (net.minecraft.tileentity.TileEntity)4 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)3 IProperty (net.minecraft.block.properties.IProperty)3 RenderItem (net.minecraft.client.renderer.entity.RenderItem)3 EnumFacing (net.minecraft.util.EnumFacing)3 ResourceLocation (net.minecraft.util.ResourceLocation)3 BlockPos (net.minecraft.util.math.BlockPos)3 AMVector3 (am2.api.math.AMVector3)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Tessellator (net.minecraft.client.renderer.Tessellator)2 ChatComponentText (net.minecraft.util.ChatComponentText)2