Java Code Examples for net.minecraft.init.Items#COAL

The following examples show how to use net.minecraft.init.Items#COAL . These examples are extracted from open source projects. 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 Project: AdvancedRocketry   File: BlockCharcoalLog.java    License: MIT License 4 votes vote down vote up
@Override
public Item getItemDropped(IBlockState state, Random rand, int fortune) {
	return Items.COAL;
}
 
Example 2
/**
 * Returns the number of ticks that the supplied fuel item will keep the furnace burning, or 0 if the item isn't fuel
 * @param stack
 * @return
 */
private static int getItemBurnTime(ItemStack stack)
{
    if (stack.isEmpty())
    {
        return 0;
    }

    int burnTime = ForgeEventFactory.getItemBurnTime(stack) * COOKTIME_DEFAULT * 3 / 400;

    if (burnTime >= 0)
    {
        return burnTime;
    }

    Item item = stack.getItem();

    if (item instanceof ItemBlock && Block.getBlockFromItem(item) != Blocks.AIR)
    {
        Block block = Block.getBlockFromItem(item);
        if (block.getDefaultState().getMaterial() == Material.WOOD) { return COOKTIME_DEFAULT * 225 / 100; }
        if (block == Blocks.COAL_BLOCK) { return COOKTIME_DEFAULT * 120; }
        if (block == Blocks.WOODEN_SLAB) { return COOKTIME_DEFAULT * 45 / 40; }
        if (block == Blocks.SAPLING) return COOKTIME_DEFAULT * 3 / 4;
    }
    else
    {
        if (item == Items.COAL) return COOKTIME_DEFAULT * 12;
        if (item == Items.BLAZE_ROD) return COOKTIME_DEFAULT * 18;

        if (item == Items.LAVA_BUCKET) return COOKTIME_DEFAULT * 150;
        if (item == Items.STICK) return COOKTIME_DEFAULT * 3 / 4;
        if (item instanceof ItemTool && ((ItemTool)item).getToolMaterialName().equals("WOOD")) return COOKTIME_DEFAULT * 15 / 10;
        if (item instanceof ItemSword && ((ItemSword)item).getToolMaterialName().equals("WOOD")) return COOKTIME_DEFAULT * 15 / 10;
        if (item instanceof ItemHoe && ((ItemHoe)item).getMaterialName().equals("WOOD")) return COOKTIME_DEFAULT * 15 / 10;

        // Ender Furnace custom fuels
        if (item == Items.BLAZE_POWDER) return COOKTIME_DEFAULT * 9;
        if (item == Items.ENDER_PEARL) { return COOKTIME_DEFAULT * 8; }
        if (item == Items.ENDER_EYE) { return COOKTIME_DEFAULT * 17; }
    }

    return 0;
}
 
Example 3
@Test
public void ResolveInheritTwoLevelMultiple() throws Exception{
	DungeonSettings main = new DungeonSettings();
	DungeonSettings child = new DungeonSettings();
	DungeonSettings sibling = new DungeonSettings();
	DungeonSettings grandchild = new DungeonSettings();
	
	SettingsContainer settings = new SettingsContainer();
	
	main.id = new SettingIdentifier("main");
	child.id = new SettingIdentifier("child");
	sibling.id = new SettingIdentifier("sibling");
	grandchild.id = new SettingIdentifier("grandchild");
	settings.put(main);
	settings.put(child);
	settings.put(sibling);
	settings.put(grandchild);
	
	main.inherit.add(child.id);
	main.inherit.add(sibling.id);
	child.inherit.add(grandchild.id);
	
	ItemStack stick = new ItemStack(Items.STICK);
	ItemStack coal = new ItemStack(Items.COAL);
	ItemStack diamond = new ItemStack(Items.DIAMOND);
	
	child.lootRules.add(Treasure.REWARD, new WeightedChoice<ItemStack>(stick , 1), 0, true, 1);
	sibling.lootRules.add(Treasure.REWARD, new WeightedChoice<ItemStack>(coal , 1), 0, true, 1);
	grandchild.lootRules.add(Treasure.REWARD, new WeightedChoice<ItemStack>(diamond , 1), 0, true, 1);
	
	DungeonSettings assembled = SettingsResolver.processInheritance(main, settings);
	
	TreasureManager treasure = new TreasureManager();
	MockChest chest = new MockChest(Treasure.REWARD, 0);
	treasure.add(chest);
	
	assertTrue(chest.count(stick) == 0);
	assertTrue(chest.count(coal) == 0);
	assertTrue(chest.count(diamond) == 0);
	
	assembled.lootRules.process(new Random(), treasure);
	
	assertTrue(chest.count(new ItemStack(Items.BOAT)) == 0);
	assertTrue(chest.count(coal) == 1);
	assertTrue(chest.count(stick) == 1);
	assertTrue(chest.count(diamond) == 1);
	
}