Worked on compost data
Created a class that i might latter move to the core to allow tracking of blocks/items that can decay over time to create compost matter. Which will later be crafted into biofuel or fertilizer for use on crops.
This commit is contained in:
parent
e7e138f156
commit
e05e6fad86
5 changed files with 70 additions and 0 deletions
47
src/dark/api/farm/DecayMatterList.java
Normal file
47
src/dark/api/farm/DecayMatterList.java
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
package dark.api.farm;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import dark.core.helpers.Pair;
|
||||||
|
|
||||||
|
public class DecayMatterList
|
||||||
|
{
|
||||||
|
//TODO handle special cases of single stack items that have non-meta damage values
|
||||||
|
public static HashMap<Pair<Integer, Integer>, Pair<Integer, Integer>> compostList = new HashMap<Pair<Integer, Integer>, Pair<Integer, Integer>>();
|
||||||
|
static
|
||||||
|
{
|
||||||
|
//TODO add some items here but leave most of the work to some of the sub methods that will ID and upload all crop like blocks
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Used to flag and itemStack as decayable matter for the compost box and later real time world
|
||||||
|
* decay
|
||||||
|
*
|
||||||
|
* @param stack - itemID and meta to check against
|
||||||
|
* @param output - how many decayed matter to output
|
||||||
|
* @param time - time in which to decay the matter */
|
||||||
|
public void addDecayMatter(ItemStack stack, int output, int time)
|
||||||
|
{
|
||||||
|
if (stack != null)
|
||||||
|
{
|
||||||
|
Pair<Integer, Integer> par = new Pair<Integer, Integer>(stack.itemID, stack.getItemDamage());
|
||||||
|
Pair<Integer, Integer> par2 = new Pair<Integer, Integer>(output, time);
|
||||||
|
if (!compostList.containsKey(par))
|
||||||
|
{
|
||||||
|
compostList.put(par, par2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isDecayMatter(ItemStack stack)
|
||||||
|
{
|
||||||
|
return stack != null && compostList.containsKey(new Pair<Integer, Integer>(stack.itemID, stack.getItemDamage()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Called after all mods/blocks have loaded to auto sort threw blocks looking for anything that
|
||||||
|
* might be close to decayable matter */
|
||||||
|
public static void triggerPostBlockAddition()
|
||||||
|
{
|
||||||
|
//TODO parse the list of blocks and auto add all crop blocks.
|
||||||
|
}
|
||||||
|
}
|
|
@ -21,6 +21,7 @@ import cpw.mods.fml.common.SidedProxy;
|
||||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||||
|
import dark.api.farm.DecayMatterList;
|
||||||
import dark.core.BlockRegistry;
|
import dark.core.BlockRegistry;
|
||||||
import dark.core.BlockRegistry.BlockData;
|
import dark.core.BlockRegistry.BlockData;
|
||||||
import dark.core.DarkMain;
|
import dark.core.DarkMain;
|
||||||
|
@ -79,6 +80,7 @@ public class FarmTech extends ModPrefab
|
||||||
{
|
{
|
||||||
super.postInit(event);
|
super.postInit(event);
|
||||||
proxy.postInit();
|
proxy.postInit();
|
||||||
|
DecayMatterList.triggerPostBlockAddition();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -11,9 +11,13 @@ import dark.core.helpers.Pair;
|
||||||
import dark.farmtech.FarmTech;
|
import dark.farmtech.FarmTech;
|
||||||
import dark.prefab.BlockMachine;
|
import dark.prefab.BlockMachine;
|
||||||
|
|
||||||
|
/** Prefab class for all farm blocks to remove the need for some configuration of the super class
|
||||||
|
*
|
||||||
|
* @author Darkguardsman */
|
||||||
public abstract class BlockFT extends BlockMachine implements IExtraObjectInfo
|
public abstract class BlockFT extends BlockMachine implements IExtraObjectInfo
|
||||||
{
|
{
|
||||||
private boolean hasConfigFile = false;
|
private boolean hasConfigFile = false;
|
||||||
|
|
||||||
public BlockFT(String name, int blockID, Material material)
|
public BlockFT(String name, int blockID, Material material)
|
||||||
{
|
{
|
||||||
super(name, FarmTech.CONFIGURATION, blockID, material);
|
super(name, FarmTech.CONFIGURATION, blockID, material);
|
||||||
|
|
|
@ -1,6 +1,20 @@
|
||||||
package dark.farmtech.machines;
|
package dark.farmtech.machines;
|
||||||
|
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
|
|
||||||
public class TileEntityCompBox extends TileEntityFT
|
public class TileEntityCompBox extends TileEntityFT
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canStore(ItemStack stack, int slot, ForgeDirection side)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canRemove(ItemStack stack, int slot, ForgeDirection side)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,9 @@ package dark.farmtech.machines;
|
||||||
import dark.farmtech.FarmTech;
|
import dark.farmtech.FarmTech;
|
||||||
import dark.prefab.TileEntityMachine;
|
import dark.prefab.TileEntityMachine;
|
||||||
|
|
||||||
|
/** Prefab class for all farm blocks to remove the need for some configuration of the super class
|
||||||
|
*
|
||||||
|
* @author Darkguardsman */
|
||||||
public abstract class TileEntityFT extends TileEntityMachine
|
public abstract class TileEntityFT extends TileEntityMachine
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue