Java Code Examples for net.minecraft.item.Item.getItemFromBlock()

The following are Jave code examples for showing how to use getItemFromBlock() of the net.minecraft.item.Item class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: OpenFlexiTrack   File: OFTRegistry.java   View Source Code Vote up 6 votes
/**
 * Registers the given block.
 * Also adds the respective TileEntity if the block has one.
 * 
 * @param registerItemBlock - {@code true} to also register the block as item.
 */
private static void registerBlock(Block block, boolean registerItemBlock) {//TODO REGISTRY - Register block names with "oft." -prefix to avoid name clash between mods.

	/* Determine block's unlocalised name. */
	String name = block.getClass().getSimpleName().toLowerCase().substring(5);

	/* Register block (and its TileEntity, if existent). */
	if (block.getRegistryName() == null) {
		GameRegistry.register(block.setRegistryName(name).setUnlocalizedName(name));

		if(block instanceof ITileEntityProvider){
			Class<? extends TileEntity> tileEntityClass = ((ITileEntityProvider) block).createNewTileEntity(null, 0).getClass();
			GameRegistry.registerTileEntity(tileEntityClass, tileEntityClass.getSimpleName());
		}
	}

	/* Register block's item if required. */
	if (registerItemBlock && Item.getItemFromBlock(block) == null) {
		GameRegistry.register(new ItemBlock(block).setRegistryName(name));
	}
}
 
Example 2
Project: CustomWorldGen   File: Block.java   View Source Code Vote up 6 votes
@Nullable
protected ItemStack createStackedBlock(IBlockState state)
{
    Item item = Item.getItemFromBlock(this);

    if (item == null)
    {
        return null;
    }
    else
    {
        int i = 0;

        if (item.getHasSubtypes())
        {
            i = this.getMetaFromState(state);
        }

        return new ItemStack(item, 1, i);
    }
}
 
Example 3
Project: connor41-etfuturum2   File: EntityArmourStand.java   View Source Code Vote up 6 votes
private void func_175422_a(EntityPlayer player, int slot) {
	ItemStack itemstack = getEquipmentInSlot(slot);

	int j = player.inventory.currentItem;
	ItemStack itemstack1 = player.inventory.getStackInSlot(j);
	ItemStack itemstack2;

	if (player.capabilities.isCreativeMode && (itemstack == null || itemstack.getItem() == Item.getItemFromBlock(Blocks.air)) && itemstack1 != null) {
		itemstack2 = itemstack1.copy();
		itemstack2.stackSize = 1;
		setCurrentItemOrArmor(slot, itemstack2);
	} else if (itemstack1 != null && itemstack1.stackSize > 1) {
		if (itemstack == null) {
			itemstack2 = itemstack1.copy();
			itemstack2.stackSize = 1;
			setCurrentItemOrArmor(slot, itemstack2);
			itemstack1.stackSize--;
		}
	} else {
		setCurrentItemOrArmor(slot, itemstack1);
		player.inventory.setInventorySlotContents(j, itemstack);
	}
}
 
Example 4
Project: DecompiledMinecraft   File: BlockGravel.java   View Source Code Vote up 5 votes
/**
 * Get the Item that this Block should drop when harvested.
 */
public Item getItemDropped(IBlockState state, Random rand, int fortune)
{
    if (fortune > 3)
    {
        fortune = 3;
    }

    return rand.nextInt(10 - fortune * 3) == 0 ? Items.flint : Item.getItemFromBlock(this);
}
 
Example 5
Project: DecompiledMinecraft   File: BlockEnderChest.java   View Source Code Vote up 4 votes
/**
 * Get the Item that this Block should drop when harvested.
 */
public Item getItemDropped(IBlockState state, Random rand, int fortune)
{
    return Item.getItemFromBlock(Blocks.obsidian);
}
 
Example 6
Project: CustomWorldGen   File: Block.java   View Source Code Vote up 4 votes
/**
 * Get the Item that this Block should drop when harvested.
 */
@Nullable
public Item getItemDropped(IBlockState state, Random rand, int fortune)
{
    return Item.getItemFromBlock(this);
}
 
Example 7
Project: Technical   File: Washer.java   View Source Code Vote up 4 votes
public Item getItemDropped(int par1, Random random, int par2) {
	return Item.getItemFromBlock(TechnicalBlock.WasherIdle);
}
 
Example 8
Project: Backmemed   File: BlockDaylightDetector.java   View Source Code Vote up 4 votes
/**
 * Get the Item that this Block should drop when harvested.
 */
public Item getItemDropped(IBlockState state, Random rand, int fortune)
{
    return Item.getItemFromBlock(Blocks.DAYLIGHT_DETECTOR);
}
 
Example 9
Project: BetterBeginningsReborn   File: ContainerSmelter.java   View Source Code Vote up 4 votes
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int fromId)
{
	ItemStack movedStackDupe = null;
	Slot slot = (Slot)inventorySlots.get(fromId);

	if (slot != null && slot.getHasStack())
	{
		ItemStack movedStack = slot.getStack();
		movedStackDupe = movedStack.copy();

		if (fromId == TileEntitySmelter.OUTPUT)
		{
			if (!mergeItemStack(movedStack, 4, 40, true))
			{
				return null;
			}
			slot.onSlotChange(movedStack, movedStackDupe);
		}
		else if (fromId != TileEntitySmelter.FUEL && fromId != TileEntitySmelter.INPUT &&
				fromId != TileEntitySmelter.BOOSTER)
		{
			if (SmelterRecipeHandler.instance().getSmeltingResult(movedStack) != null)
			{
				if (!mergeItemStack(movedStack, TileEntitySmelter.INPUT, TileEntitySmelter.INPUT + 1, false))
				{
					return null;
				}
			}
			else if (movedStack.getItem() == Item.getItemFromBlock(Blocks.GRAVEL))
			{
				if (!mergeItemStack(movedStack, TileEntitySmelter.BOOSTER, TileEntitySmelter.BOOSTER + 1, false))
				{
					return null;
				}
			}
			else if (FuelRegistry.getBurnTime(FuelConsumerType.SMELTER, movedStack) > 0)
			{
				if (!mergeItemStack(movedStack, TileEntitySmelter.FUEL, TileEntitySmelter.FUEL + 1, false))
				{
					return null;
				}
			}
			else if (fromId >= 4 && fromId < 31)
			{
				if (!mergeItemStack(movedStack, 31, 40, false))
				{
					return null;
				}
			}
			else if (fromId >= 31 && fromId < 40 && !mergeItemStack(movedStack, 4, 31, false))
			{
				return null;
			}
		}
		else if (!mergeItemStack(movedStack, 4, 40, false))
		{
			return null;
		}
		if (movedStack.getCount() == 0)
		{
			slot.putStack(null);
		}
		else
		{
			slot.onSlotChanged();
		}
		if (movedStack.getCount() == movedStackDupe.getCount())
		{
			return null;
		}
		slot.onTake(player, movedStack);
	}
	return movedStackDupe;
}
 
Example 10
Project: Technical   File: ElectricFurnaceAdvanced.java   View Source Code Vote up 4 votes
public Item getItem(World world, int par2, int par3, int par4) {
	return Item.getItemFromBlock(TechnicalBlock.ElectricFurnaceAdvancedIdle);
}
 
Example 11
Project: DecompiledMinecraft   File: BlockHay.java   View Source Code Vote up 4 votes
protected ItemStack createStackedBlock(IBlockState state)
{
    return new ItemStack(Item.getItemFromBlock(this), 1, 0);
}
 
Example 12
Project: Backmemed   File: Block.java   View Source Code Vote up 4 votes
/**
 * Get the Item that this Block should drop when harvested.
 */
public Item getItemDropped(IBlockState state, Random rand, int fortune)
{
    return Item.getItemFromBlock(this);
}
 
Example 13
Project: DecompiledMinecraft   File: BlockStoneSlabNew.java   View Source Code Vote up 4 votes
/**
 * Get the Item that this Block should drop when harvested.
 */
public Item getItemDropped(IBlockState state, Random rand, int fortune)
{
    return Item.getItemFromBlock(Blocks.stone_slab2);
}
 
Example 14
Project: connor41-etfuturum2   File: OldGravel.java   View Source Code Vote up 4 votes
@Override
public Item getItemDropped(int meta, Random rand, int fortune) {
	return Item.getItemFromBlock(this);
}
 
Example 15
Project: Technical   File: GrinderMedium.java   View Source Code Vote up 4 votes
public Item getItem(World world, int par2, int par3, int par4) {
	return Item.getItemFromBlock(TechnicalBlock.GrinderMediumIdle);
}
 
Example 16
Project: BaseClient   File: BlockObsidian.java   View Source Code Vote up 4 votes
/**
 * Get the Item that this Block should drop when harvested.
 */
public Item getItemDropped(IBlockState state, Random rand, int fortune)
{
    return Item.getItemFromBlock(Blocks.obsidian);
}
 
Example 17
Project: DecompiledMinecraft   File: EntitySheep.java   View Source Code Vote up 4 votes
protected Item getDropItem()
{
    return Item.getItemFromBlock(Blocks.wool);
}
 
Example 18
Project: BaseClient   File: BlockEnderChest.java   View Source Code Vote up 4 votes
/**
 * Get the Item that this Block should drop when harvested.
 */
public Item getItemDropped(IBlockState state, Random rand, int fortune)
{
    return Item.getItemFromBlock(Blocks.obsidian);
}
 
Example 19
Project: DecompiledMinecraft   File: BlockLeaves.java   View Source Code Vote up 4 votes
/**
 * Get the Item that this Block should drop when harvested.
 */
public Item getItemDropped(IBlockState state, Random rand, int fortune)
{
    return Item.getItemFromBlock(Blocks.sapling);
}
 
Example 20
Project: CustomWorldGen   File: BlockFurnace.java   View Source Code Vote up 4 votes
/**
 * Get the Item that this Block should drop when harvested.
 */
@Nullable
public Item getItemDropped(IBlockState state, Random rand, int fortune)
{
    return Item.getItemFromBlock(Blocks.FURNACE);
}