Search in sources :

Example 66 with ItemBlock

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

the class SchematicMask method placeInWorld.

@Override
public void placeInWorld(IBuilderContext context, BlockPos pos, List<ItemStack> stacks) {
    if (isConcrete) {
        if (stacks.size() == 0 || !BuildCraftAPI.isSoftBlock(context.world(), pos)) {
            return;
        } else {
            ItemStack stack = stacks.get(0);
            EntityPlayer player = BuildCraftAPI.fakePlayerProvider.getBuildCraftPlayer((WorldServer) context.world()).get();
            // force the block to be air block, in case it's just a soft
            // block which replacement is not straightforward
            context.world().setBlockToAir(pos);
            // Find nearest solid surface to place on
            EnumFacing solidFace = null;
            for (EnumFacing face : EnumFacing.values()) {
                BlockPos offset = pos.offset(face);
                if (!BuildCraftAPI.isSoftBlock(context.world(), offset)) {
                    solidFace = face;
                    break;
                }
            }
            ItemBlock itemBlock = (ItemBlock) stack.getItem();
            IBlockState state = itemBlock.block.onBlockPlaced(context.world(), pos, solidFace, 0, 0, 0, stack.getMetadata(), player);
            itemBlock.placeBlockAt(stack, player, context.world(), pos, solidFace, 0, 0, 0, state);
        }
    } else {
        context.world().setBlockToAir(pos);
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) EnumFacing(net.minecraft.util.EnumFacing) EntityPlayer(net.minecraft.entity.player.EntityPlayer) WorldServer(net.minecraft.world.WorldServer) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack) ItemBlock(net.minecraft.item.ItemBlock)

Example 67 with ItemBlock

use of net.minecraft.item.ItemBlock in project Traverse by ProfessorProspector.

the class TraverseBlocks method registerBlock.

static void registerBlock(Block block) {
    GameRegistry.register(block);
    GameRegistry.register(new ItemBlock(block), block.getRegistryName());
}
Also used : ItemBlock(net.minecraft.item.ItemBlock)

Example 68 with ItemBlock

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

the class BoreOreHandler method onOreEvent.

@SubscribeEvent
public void onOreEvent(OreRegisterEvent event) {
    String oreClass = event.getName();
    ItemStack ore = event.getOre();
    if (InvTools.isEmpty(ore))
        return;
    if (ore.getItem() instanceof ItemBlock && oreClass.startsWith("ore")) {
        if (EntityTunnelBore.mineableOreTags.add(oreClass))
            Game.log(Level.DEBUG, "Automation Module: Ore Tag Detected, adding to blocks Tunnel Bore can mine: {0}", oreClass);
    }
}
Also used : ItemStack(net.minecraft.item.ItemStack) ItemBlock(net.minecraft.item.ItemBlock) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 69 with ItemBlock

use of net.minecraft.item.ItemBlock in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class ModBlocks method registerBlock.

public static void registerBlock(Block block) {
    GameRegistry.register(block);
    ItemBlock Item = new ItemBlock(block);
    Item.setRegistryName(block.getRegistryName());
    GameRegistry.register(Item);
}
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