Added grinder wheel

This commit is contained in:
Calclavia 2014-01-05 15:35:42 +08:00
parent 2357384a8c
commit 474fb6d529
6 changed files with 93 additions and 4 deletions

View file

@ -8,7 +8,7 @@ import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.common.MinecraftForge;
import resonantinduction.core.render.BlockRenderingHandler;
import resonantinduction.core.render.RenderRIItem;
import resonantinduction.machine.crusher.ItemDust;
import resonantinduction.machine.grinder.ItemDust;
import resonantinduction.transport.battery.RenderBattery;
import resonantinduction.transport.battery.TileBattery;
import resonantinduction.transport.fx.FXElectricBolt;

View file

@ -27,9 +27,10 @@ import org.modstats.ModstatInfo;
import org.modstats.Modstats;
import resonantinduction.machine.BlockMachinePart;
import resonantinduction.machine.crusher.ItemDust;
import resonantinduction.machine.furnace.BlockAdvancedFurnace;
import resonantinduction.machine.furnace.TileAdvancedFurnace;
import resonantinduction.machine.grinder.BlockGrinderWheel;
import resonantinduction.machine.grinder.ItemDust;
import resonantinduction.machine.liquid.BlockFluidMixture;
import resonantinduction.machine.liquid.TileFluidMixture;
import resonantinduction.transport.battery.BlockBattery;
@ -164,7 +165,7 @@ public class ResonantInduction
// Blocks
public static Block blockTesla, blockEMContractor, blockBattery, blockAdvancedFurnace,
blockMachinePart, blockFluidMixture;
blockMachinePart, blockGrinderWheel, blockFluidMixture;
public static Fluid MIXTURE;
@ -208,6 +209,7 @@ public class ResonantInduction
blockEMContractor = new BlockLevitator(getNextBlockID());
blockBattery = new BlockBattery(getNextBlockID());
blockMachinePart = new BlockMachinePart(getNextBlockID());
blockGrinderWheel = new BlockGrinderWheel(getNextBlockID());
MIXTURE = new Fluid("mixture");
FluidRegistry.registerFluid(MIXTURE);

View file

@ -0,0 +1,26 @@
package resonantinduction.machine.grinder;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import resonantinduction.core.base.BlockBase;
/**
* A block used to build machines.
*
* @author Calclavia
*
*/
public class BlockGrinderWheel extends BlockBase implements ITileEntityProvider
{
public BlockGrinderWheel(int id)
{
super("grindingWheel", id);
}
@Override
public TileEntity createNewTileEntity(World world)
{
return new TileGrinderWheel();
}
}

View file

@ -1,4 +1,4 @@
package resonantinduction.machine.crusher;
package resonantinduction.machine.grinder;
import java.awt.Color;
import java.awt.image.BufferedImage;

View file

@ -0,0 +1,60 @@
package resonantinduction.machine.grinder;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
import resonantinduction.api.MachineRecipes;
import resonantinduction.api.MachineRecipes.RecipeType;
import resonantinduction.api.RecipeUtils.ItemStackResource;
import resonantinduction.api.RecipeUtils.Resource;
import calclavia.lib.prefab.tile.TileElectrical;
/**
* @author Calclavia
*
*/
public class TileGrinderWheel extends TileElectrical
{
/** A map of ItemStacks and their remaining grind-time left. */
public static final HashMap<EntityItem, Integer> map = new HashMap<EntityItem, Integer>();
public void doWork()
{
Iterator<Entry<EntityItem, Integer>> it = map.entrySet().iterator();
while (it.hasNext())
{
Entry<EntityItem, Integer> entry = it.next();
entry.setValue(entry.getValue() - 1);
if (entry.getValue() <= 0)
{
this.doGrind(entry.getKey());
}
}
}
private boolean canGrind(ItemStack itemStack)
{
return MachineRecipes.INSTANCE.getRecipes(RecipeType.GRINDER).containsKey(itemStack);
}
private void doGrind(EntityItem entity)
{
ItemStack itemStack = entity.getEntityItem();
List<Resource> results = MachineRecipes.INSTANCE.getRecipes(RecipeType.GRINDER).get(itemStack);
for (Resource resource : results)
{
if (resource instanceof ItemStackResource)
{
entity.setEntityItemStack(((ItemStackResource) resource).itemStack);
}
}
}
}

View file

@ -14,6 +14,7 @@ tile.resonantinduction\:tesla.name=Tesla Coil
tile.resonantinduction\:contractor.name=Electromagnetic Levitator
tile.resonantinduction\:battery.name=Battery
tile.resonantinduction\:machinePart.name=Machine Part
tile.resonantinduction\:grindingWheel.name=Grinding Wheel
tile.resonantinduction\:filter.name=Filter
## Items