net.minecraft.item.ItemBlock Java Examples

The following examples show how to use net.minecraft.item.ItemBlock. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WorldEventsCommon.java    From Valkyrien-Skies with Apache License 2.0 7 votes vote down vote up
@SubscribeEvent
public void onAttachCapabilityEventItem(AttachCapabilitiesEvent event) {
    if (event.getObject() instanceof ItemStack) {
        ItemStack stack = (ItemStack) event.getObject();
        Item item = stack.getItem();

        if (item instanceof ItemValkyriumCrystal) {
            event.addCapability(
                new ResourceLocation(ValkyrienSkiesWorld.MOD_ID, "AntiGravityValue"),
                new AntiGravityCapabilityProvider(VSConfig.valkyriumCrystalForce));
        }
        if (stack.getItem() instanceof ItemBlock) {
            ItemBlock blockItem = (ItemBlock) stack.getItem();
            if (blockItem.getBlock() instanceof BlockValkyriumOre) {
                event.addCapability(
                    new ResourceLocation(ValkyrienSkiesWorld.MOD_ID, "AntiGravityValue"),
                    new AntiGravityCapabilityProvider(VSConfig.valkyriumOreForce));
            }
        }
    }
}
 
Example #2
Source File: BlockDrawbridge.java    From enderutilities with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public ItemBlock createItemBlock()
{
    ItemBlockPlacementProperty item = new ItemBlockPlacementProperty(this);
    String[] names = new String[] { "extend", "retract", "toggle" };

    item.addPlacementProperty(0, "drawbridge.delay", Constants.NBT.TAG_BYTE, 1, 255);
    item.addPlacementProperty(0, "drawbridge.length", Constants.NBT.TAG_BYTE, 1, TileEntityDrawbridge.MAX_LENGTH_NORMAL);
    item.addPlacementProperty(0, "drawbridge.redstone_mode", Constants.NBT.TAG_BYTE, 0, 2);
    item.addPlacementPropertyValueNames(0, "drawbridge.redstone_mode", names);

    item.addPlacementProperty(1, "drawbridge.delay", Constants.NBT.TAG_BYTE, 1, 255);
    item.addPlacementProperty(1, "drawbridge.length", Constants.NBT.TAG_BYTE, 1, TileEntityDrawbridge.MAX_LENGTH_ADVANCED);
    item.addPlacementProperty(1, "drawbridge.redstone_mode", Constants.NBT.TAG_BYTE, 0, 2);
    item.addPlacementPropertyValueNames(1, "drawbridge.redstone_mode", names);
    return item;
}
 
Example #3
Source File: BlockQBlock.java    From qcraft-mod with Apache License 2.0 6 votes vote down vote up
public IIcon getIconForType( int side, int type, Appearance appearance )
{
    if( appearance == Appearance.Swirl )
    {
        return s_swirlIcon;
    }
    else if( appearance == Appearance.Fuzz )
    {
        return s_fuzzIcon;
    }
    else //if( appearance == Appearance.Block )
    {
        ItemStack[] blockList = getImpostorBlockList();
        if( type >= 0 && type < blockList.length )
        {
            ItemStack item = blockList[ type ];
            if( item != null )
            {
                Block block = ((ItemBlock)item.getItem()).field_150939_a;
                int damage = item.getItemDamage();
                return block.getIcon( side, damage );
            }
        }
        return s_transparentIcon;
    }
}
 
Example #4
Source File: ModSubstitutions.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static void preInit() {
        if(ModConfig.enableAdditionalNodeTypes) {
            try {
                ItemBlock item = (ItemBlock) Item.getItemFromBlock(ConfigBlocks.blockAiry);

                item.field_150939_a = RegisteredBlocks.blockNode;

                //Hacky way
                FMLControlledNamespacedRegistry<Block> registry = GameData.getBlockRegistry();
                registry.underlyingIntegerMap.field_148749_a.put(RegisteredBlocks.blockNode, Block.getIdFromBlock(ConfigBlocks.blockAiry));
                registry.underlyingIntegerMap.field_148748_b.set(Block.getIdFromBlock(ConfigBlocks.blockAiry), RegisteredBlocks.blockNode);
                ((BiMap)registry.field_148758_b).forcePut(RegisteredBlocks.blockNode, registry.field_148758_b.get(ConfigBlocks.blockAiry));

                registry.underlyingIntegerMap.field_148749_a.remove(ConfigBlocks.blockAiry);

                ConfigBlocks.blockAiry = RegisteredBlocks.blockNode;
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
}
 
Example #5
Source File: CustomWoodTypeRegistry.java    From AgriCraft with MIT License 6 votes vote down vote up
private static void init(Function<ItemBlock, IntStream> getItemDamages) {
    if (!WOOD_TYPES.isEmpty()) {
        return;
    }
    OreDictionary.getOres("plankWood").stream()
            .filter(plank -> plank.getItem() instanceof ItemBlock)
            .flatMap(plank -> {
                ItemBlock block = ((ItemBlock) plank.getItem());
                if (plank.getItemDamage() == OreDictionary.WILDCARD_VALUE) {
                    return getItemDamages.apply(block).mapToObj(meta -> new CustomWoodType(block.getBlock(), meta));
                } else {
                    return Stream.of(new CustomWoodType(block.getBlock(), plank.getItemDamage()));
                }
            })
            .forEach(type -> WOOD_TYPES.put(type.toString(), type));
}
 
Example #6
Source File: MixinTileEntityFurnace.java    From Production-Line with MIT License 6 votes vote down vote up
@Inject(method = "update", at = @At("RETURN"))
private void onUpdate(CallbackInfo callbackInfo) {
    if (!this.world.isRemote) {
        if (this.isBurning()) {
            ItemStack itemStack = this.furnaceItemStacks[0];
            if (itemStack != null) {
                if (itemStack.getItem() instanceof ItemBlock) {
                    Block block = ((ItemBlock) itemStack.getItem()).block;
                    if (block.getMaterial(block.getStateFromMeta(itemStack.getMetadata())) == Material.TNT) {
                        this.doExplosion();
                    }
                } else if (itemStack.getItem() == Items.GUNPOWDER) {
                    this.doExplosion();
                } else if (itemStack.getItem() instanceof ItemFirework || itemStack.getItem()
                        instanceof ItemFireworkCharge) {
                    this.doExplosion();
                }
            }
        }
    }
}
 
Example #7
Source File: RenderChiselSnowman.java    From Chisel-2 with GNU General Public License v2.0 6 votes vote down vote up
protected void renderEquippedItems(EntityChiselSnowman snowman, float size){
    super.renderEquippedItems(snowman, size);
    ItemStack itemStack = snowman.getEquipmentInSlot(2);

    if(itemStack.getItem() instanceof ItemBlock){
        GL11.glPushMatrix();
        this.snowMan.head.postRender(0.0625F);

        IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(itemStack, EQUIPPED);
        boolean is3D = (customRenderer != null && customRenderer.shouldUseRenderHelper(EQUIPPED, itemStack, BLOCK_3D));

        if(is3D || RenderBlocks.renderItemIn3d(Block.getBlockFromItem(itemStack.getItem()).getRenderType())){
            float f1 = 0.625F;
            GL11.glTranslatef(0.0F, -0.34375F, 0.0F);
            GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F);
            GL11.glScalef(f1, -f1, f1);
        }
        this.renderManager.itemRenderer.renderItem(snowman, itemStack, 0);
        GL11.glPopMatrix();
    }
}
 
Example #8
Source File: SignalsConfig.java    From Signals with GNU General Public License v3.0 6 votes vote down vote up
public void initDefaults(){
    if(validItems.length == 0) {
        List<Item> items = new ArrayList<>();
        items.add(ModItems.RAIL_CONFIGURATOR);
        items.add(Item.getItemFromBlock(ModBlocks.RAIL_LINK));

        for(Item item : Item.REGISTRY) {
            if(item instanceof ItemBlock) {
                Block block = ((ItemBlock)item).getBlock();
                if(block instanceof BlockSignalBase || block instanceof BlockRailBase) {
                    items.add(item);
                }
            }
        }

        validItems = new String[items.size()];
        for(int i = 0; i < items.size(); i++) {
            validItems[i] = Item.REGISTRY.getNameForObject(items.get(i)).toString();
        }
    }
}
 
Example #9
Source File: BlockRegistry.java    From Logistics-Pipes-2 with MIT License 6 votes vote down vote up
/**
 * Registers all registered Blocks on Startup.
 * Call this in preInit on the Common Proxy
 */
public static void init() {
	//init Blocks
	registry.add(new BlockOreRutile());
	
	for(LPBlockBase block : registry) {

		//Register Block
		GameRegistry.register(block);
		//Register Item of Block
		GameRegistry.register(new ItemBlock(block), block.getRegistryName());
		//Register Ores
		if(!StringUtil.isNullOrWhitespace(block.getOreName()) && !StringUtil.isNullOrEmpty(block.getOreName()))
			OreDictionary.registerOre(block.getOreName(), block);
		
		if(block instanceof BlockOreRutile) {
			addConfiguredWorldgen(block.getDefaultState(), References.RN_ORE_RUTILE, Config.oreRutile);
		}
	}
}
 
Example #10
Source File: MinecraftTypeHelper.java    From malmo with MIT License 6 votes vote down vote up
/** Attempt to parse string as a Variation, allowing for block properties having different names to the enum values<br>
 * (eg blue_orchid vs orchidBlue etc.)
 * @param part the string (potentially in the 'wrong' format, eg 'orchidBlue')
 * @param is the ItemStack from which this string came (eg from is.getUnlocalisedName)
 * @return a Variation, if one exists, that matches the part string passed in, or one of the ItemStacks current property values.
 */
public static Variation attemptToGetAsVariant(String part, ItemStack is)
{
    if (is.getItem() instanceof ItemBlock)
    {
        // Unlocalised name doesn't always match the names we use in types.xsd
        // (which are the names displayed by Minecraft when using the F3 debug etc.)
        ItemBlock ib = (ItemBlock)(is.getItem());
        IBlockState bs = ib.block.getStateFromMeta(is.getMetadata());
        for (IProperty prop : bs.getProperties().keySet())
        { 
            Comparable<?> comp = bs.getValue(prop);
            Variation var = attemptToGetAsVariant(comp.toString());
            if (var != null)
                return var;
        }
        return null;
    }
    else
        return attemptToGetAsVariant(part);
}
 
Example #11
Source File: BlockTerra.java    From TFC2 with GNU General Public License v3.0 6 votes vote down vote up
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void getSubBlocks(Item itemIn, CreativeTabs tab, NonNullList list)
{
	if(showInCreative)
	{
		if(hasMeta())
		{
			if(itemIn instanceof ItemBlock && ((ItemBlock)itemIn).block instanceof INeedOffset)
			{
				for(int l = 0; l < META_PROP.getAllowedValues().size(); l++)
					list.add(new ItemStack(itemIn, 1, ((INeedOffset)(((ItemBlock)itemIn).block)).convertMetaToItem(l)));
			}
			else
			{
				for(int l = 0; l < META_PROP.getAllowedValues().size(); l++)
					list.add(new ItemStack(itemIn, 1, l));
			}
		}
		else
			super.getSubBlocks(itemIn, tab, list);
	}
}
 
Example #12
Source File: BlockCharger.java    From Cyberware with MIT License 6 votes vote down vote up
public BlockCharger()
{
	super(Material.IRON);
	setHardness(5.0F);
	setResistance(10.0F);
	setSoundType(SoundType.METAL);
	
	String name = "charger";
	
	this.setRegistryName(name);
	GameRegistry.register(this);

	ItemBlock ib = new ItemBlockCyberware(this);
	ib.setRegistryName(name);
	GameRegistry.register(ib);
	
	this.setUnlocalizedName(Cyberware.MODID + "." + name);

	this.setCreativeTab(Cyberware.creativeTab);
	GameRegistry.registerTileEntity(TileEntityCharger.class, Cyberware.MODID + ":" + name);
	
	CyberwareContent.blocks.add(this);
}
 
Example #13
Source File: BlockSurgery.java    From Cyberware with MIT License 6 votes vote down vote up
public BlockSurgery()
{
	super(Material.IRON);
	setHardness(5.0F);
	setResistance(10.0F);
	setSoundType(SoundType.METAL);
	
	String name = "surgery";
	
	this.setRegistryName(name);
	GameRegistry.register(this);

	ItemBlock ib = new ItemBlockCyberware(this);
	ib.setRegistryName(name);
	GameRegistry.register(ib);
	
	this.setUnlocalizedName(Cyberware.MODID + "." + name);

	this.setCreativeTab(Cyberware.creativeTab);
	GameRegistry.registerTileEntity(TileEntitySurgery.class, Cyberware.MODID + ":" + name);
	
	CyberwareContent.blocks.add(this);
}
 
Example #14
Source File: BlockBeacon.java    From Cyberware with MIT License 6 votes vote down vote up
public BlockBeacon()
{
	super(Material.IRON);
	setHardness(5.0F);
	setResistance(10.0F);
	setSoundType(SoundType.METAL);
	
	String name = "beacon";
	
	this.setRegistryName(name);
	GameRegistry.register(this);

	ItemBlock ib = new ItemBlockCyberware(this, "cyberware.tooltip.beacon");
	ib.setRegistryName(name);
	GameRegistry.register(ib);
	
	this.setUnlocalizedName(Cyberware.MODID + "." + name);

	this.setCreativeTab(Cyberware.creativeTab);
	GameRegistry.registerTileEntity(TileEntityBeacon.class, Cyberware.MODID + ":" + name);
	
	CyberwareContent.blocks.add(this);
}
 
Example #15
Source File: BlockBlueprintArchive.java    From Cyberware with MIT License 6 votes vote down vote up
public BlockBlueprintArchive()
{
	super(Material.IRON);
	setHardness(5.0F);
	setResistance(10.0F);
	setSoundType(SoundType.METAL);
	
	String name = "blueprintArchive";
	
	this.setRegistryName(name);
	GameRegistry.register(this);

	ItemBlock ib = new ItemBlockCyberware(this, "cyberware.tooltip.blueprintArchive");
	ib.setRegistryName(name);
	GameRegistry.register(ib);
	
	this.setUnlocalizedName(Cyberware.MODID + "." + name);

	this.setCreativeTab(Cyberware.creativeTab);
	GameRegistry.registerTileEntity(TileEntityBlueprintArchive.class, Cyberware.MODID + ":" + name);
	
	CyberwareContent.blocks.add(this);
	
	this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));
}
 
Example #16
Source File: TileEntityTreeFarm.java    From AdvancedMod with GNU General Public License v3.0 6 votes vote down vote up
private void placeSapling(){
    if(worldObj.isAirBlock(xCoord, yCoord + 2, zCoord)) {
        if(inventory != null) {
            for(int i = 0; i < inventory.getSizeInventory(); i++) {
                ItemStack stack = inventory.getStackInSlot(i);
                if(stack != null && stack.getItem() instanceof ItemBlock) {
                    Block block = ((ItemBlock)stack.getItem()).field_150939_a;
                    if(block == Blocks.sapling) {
                        worldObj.setBlock(xCoord, yCoord + 2, zCoord, block, stack.getItemDamage(), 3);
                        inventory.decrStackSize(i, 1);
                    }
                }
            }
        }
    }
}
 
Example #17
Source File: Scaffold.java    From LiquidBounce with GNU General Public License v3.0 6 votes vote down vote up
/**
 * @return hotbar blocks amount
 */
private int getBlocksAmount() {
    int amount = 0;

    for (int i = 36; i < 45; i++) {
        final ItemStack itemStack = mc.thePlayer.inventoryContainer.getSlot(i).getStack();

        if (itemStack != null && itemStack.getItem() instanceof ItemBlock) {
            final Block block = ((ItemBlock) itemStack.getItem()).getBlock();
            if (mc.thePlayer.getHeldItem() == itemStack || !InventoryUtils.BLOCK_BLACKLIST.contains(block))
                amount += itemStack.stackSize;
        }
    }

    return amount;
}
 
Example #18
Source File: ModuleInstance.java    From Wizardry with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Gets all of the itemstacks in the player's inventory that match a given itemstack
 */
public final List<ItemStack> getAllOfStackFromInventory(@Nonnull EntityPlayer player, @Nonnull ItemStack search) {
	List<ItemStack> stacks = new ArrayList<>();

	if (search.isEmpty()) return stacks;

	for (ItemStack stack : player.inventory.mainInventory) {
		if (stack == null || stack.isEmpty()) continue;
		if (!(stack.getItem() instanceof ItemBlock)) continue;

		if (!ItemStack.areItemsEqual(stack, search)) continue;

		stacks.add(stack);
	}

	return stacks;
}
 
Example #19
Source File: ModelPneumaticDoorBase.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void renderDynamic(float size, TileEntity tile, float partialTicks){
    if(tile instanceof TileEntityPneumaticDoorBase) {
        TileEntityPneumaticDoorBase door = (TileEntityPneumaticDoorBase)tile;
        ItemStack camoStack = door.getStackInSlot(TileEntityPneumaticDoorBase.CAMO_SLOT);
        boolean renderBase = true;
        if(camoStack != null && camoStack.getItem() instanceof ItemBlock) {
            Block block = Block.getBlockFromItem(camoStack.getItem());
            renderBase = !PneumaticCraftUtils.isRenderIDCamo(block.getRenderType());
        }
        PneumaticCraftUtils.rotateMatrixByMetadata(door.orientation.ordinal());
        renderModel(size, door.oldProgress + (door.progress - door.oldProgress) * partialTicks, renderBase, ((TileEntityPneumaticDoorBase)tile).rightGoing);
    } else {
        renderModel(size, 1, true, false);
    }
}
 
Example #20
Source File: BlockKitunebi.java    From Sakura_mod with MIT License 6 votes vote down vote up
private void setVisibleFlg(World world, BlockPos pos,IBlockState state) {
    world.setBlockState(pos, state.withProperty(ISVISIBLE, false));
	EntityPlayer player = world.getClosestPlayer(pos.getX() + 0.5F, pos.getY() + 0.5F, pos.getZ() + 0.5F, 5.0D, false);
	if(player ==null){
		world.setBlockState(pos, state.withProperty(ISVISIBLE, false));
		return;
	}
    ItemStack is = player.getHeldItemMainhand();
    ItemStack offis =player.getHeldItemOffhand();
    if (!is.isEmpty()||!offis.isEmpty()) {
    	Item mainItem = is.getItem(),offItem=offis.getItem();
        if (mainItem instanceof ItemBlock||offItem instanceof ItemBlock) {
            if (Block.getBlockFromItem(mainItem) == this||Block.getBlockFromItem(offItem) == this) {
                world.setBlockState(pos, state.withProperty(ISVISIBLE, true));
            }
        }
    }
}
 
Example #21
Source File: ItemDiamondChainsaw.java    From Electro-Magic-Tools with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float xOffset, float yOffset, float zOffset) {
    for (int i = 0; i < player.inventory.mainInventory.length; i++) {
        ItemStack torchStack = player.inventory.mainInventory[i];
        if (torchStack == null || !torchStack.getUnlocalizedName().toLowerCase().contains("torch")) {
            continue;
        }
        Item item = torchStack.getItem();
        if (!(item instanceof ItemBlock)) {
            continue;
        }
        int oldMeta = torchStack.getItemDamage();
        int oldSize = torchStack.stackSize;
        boolean result = torchStack.tryPlaceItemIntoWorld(player, world, x, y, z, side, xOffset, yOffset, zOffset);
        if (player.capabilities.isCreativeMode) {
            torchStack.setItemDamage(oldMeta);
            torchStack.stackSize = oldSize;
        } else if (torchStack.stackSize <= 0) {
            ForgeEventFactory.onPlayerDestroyItem(player, torchStack);
            player.inventory.mainInventory[i] = null;
        }
        if (result) {
            return true;
        }
    }

    return super.onItemUse(stack, player, world, x, y, z, side, xOffset, yOffset, zOffset);
}
 
Example #22
Source File: BlockInfestedLeaves.java    From ExNihiloAdscensio with MIT License 5 votes vote down vote up
public BlockInfestedLeaves() {
	super();
	this.setUnlocalizedName("blockInfestedLeaves");
	this.setRegistryName("blockInfestedLeaves");
	GameRegistry.<Block>register(this);
	GameRegistry.register(new ItemBlock(this).setRegistryName("blockInfestedLeaves"));
	this.setDefaultState(
			this.blockState.getBaseState().withProperty(CHECK_DECAY, false).withProperty(DECAYABLE, false));
	this.leavesFancy = true;
}
 
Example #23
Source File: BlockBaseFalling.java    From ExNihiloAdscensio with MIT License 5 votes vote down vote up
public BlockBaseFalling(SoundType sound, String name)
{
    super(Material.SAND);
    setUnlocalizedName(name);
    setRegistryName(name);
    setSoundType(sound);
    GameRegistry.register(this);
    GameRegistry.register(new ItemBlock(this).setRegistryName(name));
}
 
Example #24
Source File: BlockElevatorCaller.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ){
    TileEntityElevatorCaller te = (TileEntityElevatorCaller)world.getTileEntity(x, y, z);
    if(!world.isRemote) {
        MovingObjectPosition mop = PneumaticCraftUtils.getEntityLookedObject(player);
        if(mop != null && mop.subHit >= 0) {
            setSurroundingElevators(world, x, y, z, mop.subHit);
        } else if(player.isSneaking()) {
            te.camoStack = player.getCurrentEquippedItem();
            return te.camoStack != null && te.camoStack.getItem() instanceof ItemBlock;
        }
    }
    return te.getRotation().getOpposite().ordinal() == side;
}
 
Example #25
Source File: BigReactors.java    From BigReactors with MIT License 5 votes vote down vote up
public static void registerFuelRods(int id, boolean require) {
	if(BigReactors.blockYelloriumFuelRod == null) {
		BRConfig.CONFIGURATION.load();
		BigReactors.blockYelloriumFuelRod = new BlockFuelRod(Material.iron);
		GameRegistry.registerBlock(BigReactors.blockYelloriumFuelRod, ItemBlock.class, "YelloriumFuelRod");
		BRConfig.CONFIGURATION.save();
	}
}
 
Example #26
Source File: SchematicHelper.java    From ForgeHax with MIT License 5 votes vote down vote up
@SubscribeEvent
public void onRender(RenderEvent event) {
  if (!SchematicaHelper.isSchematicaPresent()) return;

  final ItemStack heldStack = MC.player.getHeldItemMainhand();
  if (heldStack.isEmpty()) {
    return;
  }
  if (!(heldStack.getItem() instanceof ItemBlock)) {
    return;
  }
  
  final Block block = ((ItemBlock) heldStack.getItem()).getBlock();
  final int metaData = heldStack.getMetadata();
  
  // using metadata is gay and not 1.13 compatible but dont know a better way to get blockstate from itemstack
  final IBlockState heldBlockState = block.getStateFromMeta(metaData);
  
  getBlockPlacePos().ifPresent(pos ->
      getColor(pos, heldBlockState).ifPresent(color -> {
        event.getBuffer().begin(GL11.GL_LINES, DefaultVertexFormats.POSITION_COLOR);
        GlStateManager.glLineWidth(line_width.get());
        
        GeometryTessellator.drawCuboid(event.getBuffer(), pos, GeometryMasks.Line.ALL, color);
        
        event.getTessellator().draw();
        
      })
  );
}
 
Example #27
Source File: TraverseBlocks.java    From Traverse-Legacy-1-12-2 with MIT License 5 votes vote down vote up
static void addFirTreeStuff() {
	String fir = "fir";
	FirLSCompound lsCompound = new FirLSCompound();
	register(lsCompound.lsLeaves);
	oreDictNames.put(lsCompound.lsLeaves, "treeLeaves");
	register(lsCompound.lsSapling);
	oreDictNames.put(lsCompound.lsSapling, "treeSapling");

	BlockTraverseWoodLog log = new BlockTraverseWoodLog(fir);
	register(log);
	oreDictNames.put(log, "logWood");

	BlockTraverseWoodPlanks planks = new BlockTraverseWoodPlanks(fir);
	register(planks);
	oreDictNames.put(planks, "plankWood");

	BlockTraverseStairs stairs = new BlockTraverseStairs(planks.getDefaultState(), fir);
	register(stairs);
	oreDictNames.put(stairs, "stairWood");

	BlockTraverseWoodSlab.Half halfSlab = new BlockTraverseWoodSlab.Half(fir);
	register(halfSlab, true);
	oreDictNames.put(halfSlab, "slabWood");
	BlockTraverseWoodSlab.Double doubleSlab = new BlockTraverseWoodSlab.Double(fir, halfSlab);
	register(doubleSlab, (ItemBlock) new ItemSlab(blocks.get(halfSlab.name + "_slab"), halfSlab, doubleSlab).setRegistryName(halfSlab.getRegistryName()));

	BlockTraverseWoodFence fence = new BlockTraverseWoodFence(fir);
	oreDictNames.put(fence, "fenceWood");
	register(fence);

	BlockTraverseWoodFenceGate fenceGate = new BlockTraverseWoodFenceGate(fir);
	oreDictNames.put(fence, "fenceGateWood");
	register(fenceGate);

	BlockTraverseWoodDoor door = new BlockTraverseWoodDoor(fir);
	register(door, new ItemTraverseWoodDoor(door));

}
 
Example #28
Source File: Blocks.java    From BaseMetals with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static BlockDoor createDoor(MetalMaterial metal){
	String name = metal.getName()+"_door";
	BlockDoor block = new BlockMetalDoor(metal);
	block.setRegistryName(BaseMetals.MODID, name);
	block.setUnlocalizedName(BaseMetals.MODID+"."+name);
	GameRegistry.register(block);
	
	ItemBlock itemBlock = new ItemBlock(block);
	itemBlock.setRegistryName(BaseMetals.MODID, name);
	GameRegistry.register(itemBlock);
	
	allBlocks.put(metal.getName()+"_door", block);
	return block;
}
 
Example #29
Source File: TunnellerHack.java    From ForgeWurst with GNU General Public License v3.0 5 votes vote down vote up
private boolean equipSolidBlock(BlockPos pos)
{
	for(int slot = 0; slot < 9; slot++)
	{
		// filter out non-block items
		ItemStack stack =
			WMinecraft.getPlayer().inventory.getStackInSlot(slot);
		if(WItem.isNullOrEmpty(stack)
			|| !(stack.getItem() instanceof ItemBlock))
			continue;
		
		Block block = Block.getBlockFromItem(stack.getItem());
		
		// filter out non-solid blocks
		if(!block.getDefaultState().isFullBlock())
			continue;
		
		// filter out blocks that would fall
		if(block instanceof BlockFalling && BlockFalling
			.canFallThrough(BlockUtils.getState(pos.down())))
			continue;
		
		WMinecraft.getPlayer().inventory.currentItem = slot;
		return true;
	}
	
	return false;
}
 
Example #30
Source File: ReplacementBlock.java    From BigReactors with MIT License 5 votes vote down vote up
/**
 * Called to get the metadata of the replacement block in the world.
 * @param world The world object
 * @param x The X coord
 * @param y The Y coord
 * @param z The Z coord
 * @param stack The ItemStack being used to replace the block (may be null)
 * @return The metadata of the block
 */
protected int getMeta(World world, int x, int y, int z, ItemStack stack)
{
	int m = 0;
	if (_hasMeta > 0)
	{
		if (_hasMeta > 1)
			return _meta;
		m = stack.getItemDamage();
		Item item = stack.getItem();
		if (item instanceof ItemBlock)
			m = ((ItemBlock)item).getMetadata(m);
	}
	return m;
}