ActuallyAdditions/src/main/java/de/ellpeck/actuallyadditions/mod/recipe/FuelHandler.java

74 lines
2.4 KiB
Java
Raw Normal View History

2015-08-29 14:33:25 +02:00
/*
2016-05-16 22:52:27 +02:00
* This file ("FuelHandler.java") is part of the Actually Additions mod for Minecraft.
2015-08-29 14:33:25 +02:00
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
2016-05-16 22:52:27 +02:00
* http://ellpeck.de/actaddlicense
2015-08-29 14:33:25 +02:00
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
2016-05-16 22:54:42 +02:00
* © 2015-2016 Ellpeck
2015-08-29 14:33:25 +02:00
*/
2016-01-05 04:47:35 +01:00
package de.ellpeck.actuallyadditions.mod.recipe;
2015-05-20 22:39:43 +02:00
2016-01-05 04:47:35 +01:00
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheMiscBlocks;
import de.ellpeck.actuallyadditions.mod.items.InitItems;
import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems;
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
2015-05-20 22:39:43 +02:00
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
2016-01-07 18:20:59 +01:00
import net.minecraftforge.fml.common.IFuelHandler;
import net.minecraftforge.fml.common.registry.GameRegistry;
2015-05-20 22:39:43 +02:00
2016-07-04 20:23:53 +02:00
import java.util.ArrayList;
import java.util.List;
2015-05-20 22:39:43 +02:00
public class FuelHandler implements IFuelHandler{
2016-07-04 20:23:53 +02:00
private static final List<Fuel> FUEL_LIST = new ArrayList<Fuel>();
2015-05-20 22:39:43 +02:00
public static void init(){
2015-07-01 21:32:48 +02:00
ModUtil.LOGGER.info("Initializing Fuelstuffs...");
2015-05-20 22:39:43 +02:00
GameRegistry.registerFuelHandler(new FuelHandler());
2015-10-03 10:19:40 +02:00
addFuel(InitItems.itemMisc, TheMiscItems.TINY_CHAR.ordinal(), 200);
addFuel(InitItems.itemMisc, TheMiscItems.TINY_COAL.ordinal(), 200);
addFuel(InitBlocks.blockMisc, TheMiscBlocks.CHARCOAL_BLOCK.ordinal(), 16000);
addFuel(InitItems.itemMisc, TheMiscItems.BIOCOAL.ordinal(), 80);
2015-10-03 10:19:40 +02:00
}
2016-07-04 20:23:53 +02:00
private static void addFuel(Item item, int meta, int value){
2016-07-04 22:18:58 +02:00
FUEL_LIST.add(new Fuel(new ItemStack(item, 1, meta), value));
2015-05-20 22:39:43 +02:00
}
2016-07-04 20:23:53 +02:00
private static void addFuel(Block block, int meta, int value){
addFuel(Item.getItemFromBlock(block), meta, value);
2015-05-20 22:39:43 +02:00
}
2016-07-04 20:23:53 +02:00
@Override
public int getBurnTime(ItemStack stack){
if(StackUtil.isValid(stack)){
2016-07-04 20:23:53 +02:00
for(Fuel fuel : FUEL_LIST){
if(stack.isItemEqual(fuel.fuel)){
return fuel.burnTime;
2015-05-20 22:39:43 +02:00
}
}
}
return 0;
}
2016-02-01 20:39:11 +01:00
2016-07-04 20:23:53 +02:00
private static class Fuel{
public ItemStack fuel;
public int burnTime;
public Fuel(ItemStack fuel, int burnTime){
this.fuel = fuel;
this.burnTime = burnTime;
}
2016-02-01 20:39:11 +01:00
}
2015-05-20 22:39:43 +02:00
}