moved processor recipes to core
This commit is contained in:
parent
5b7b064397
commit
b6a213b587
5 changed files with 79 additions and 144 deletions
|
@ -149,18 +149,15 @@ public class ModelCrusher extends ModelBase
|
|||
{
|
||||
pos = 0;
|
||||
}
|
||||
int delta = 0;
|
||||
switch (pos / 2)
|
||||
float delta = pos / 4;
|
||||
|
||||
if (delta < 0)
|
||||
{
|
||||
case 1:
|
||||
delta = 1;
|
||||
break;
|
||||
case 2:
|
||||
delta = 2;
|
||||
break;
|
||||
default:
|
||||
delta = 0;
|
||||
break;
|
||||
delta = 0;
|
||||
}
|
||||
if (delta > 2)
|
||||
{
|
||||
delta = 2;
|
||||
}
|
||||
leftCrusher.setRotationPoint(-3F + delta, 11F, -5F);
|
||||
rightCrusher.setRotationPoint(1F - delta, 11F, -5F);
|
||||
|
|
|
@ -8,10 +8,10 @@ import org.lwjgl.opengl.GL11;
|
|||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import dark.api.ProcessorRecipes.ProcessorType;
|
||||
import dark.assembly.client.model.ModelCrusher;
|
||||
import dark.assembly.common.AssemblyLine;
|
||||
import dark.assembly.common.machine.processor.TileEntityProcessor;
|
||||
import dark.assembly.common.machine.processor.ProcessorRecipes.ProcessorType;
|
||||
import dark.core.client.renders.RenderTileMachine;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
|
|
@ -11,6 +11,7 @@ import net.minecraft.item.crafting.FurnaceRecipes;
|
|||
import net.minecraft.tileentity.TileEntityFurnace;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import dark.api.ProcessorRecipes;
|
||||
|
||||
public class ContainerProcessor extends Container
|
||||
{
|
||||
|
|
|
@ -1,113 +0,0 @@
|
|||
package dark.assembly.common.machine.processor;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import dark.core.prefab.helpers.Pair;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ProcessorRecipes
|
||||
{
|
||||
public static HashMap<Pair<Integer, Integer>, ItemStack> crusherRecipes = new HashMap();
|
||||
public static HashMap<Pair<Integer, Integer>, ItemStack> grinderrRecipes = new HashMap();
|
||||
public static HashMap<Pair<Integer, Integer>, ItemStack> pressRecipes = new HashMap();
|
||||
|
||||
static
|
||||
{
|
||||
createABRecipe(ProcessorType.CRUSHER, new ItemStack(Block.stone.blockID, 1, 0), new ItemStack(Block.cobblestone.blockID, 1, 0));
|
||||
}
|
||||
|
||||
public static void createABRecipe(ProcessorType type, Object in, Object out)
|
||||
{
|
||||
if (in != null && out != null)
|
||||
{
|
||||
ItemStack input = convert(in);
|
||||
ItemStack output = convert(out);
|
||||
if (input != null && output != null)
|
||||
{
|
||||
HashMap<Pair<Integer, Integer>, ItemStack> map = null;
|
||||
switch (type)
|
||||
{
|
||||
case CRUSHER:
|
||||
map = crusherRecipes;
|
||||
break;
|
||||
case GRINDER:
|
||||
map = grinderrRecipes;
|
||||
break;
|
||||
case PRESS:
|
||||
map = pressRecipes;
|
||||
break;
|
||||
}
|
||||
if (map != null && !crusherRecipes.containsKey(input))
|
||||
{
|
||||
crusherRecipes.put(new Pair<Integer, Integer>(input.itemID, input.getItemDamage()), output);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static ItemStack convert(Object object)
|
||||
{
|
||||
if (object instanceof ItemStack)
|
||||
{
|
||||
return (ItemStack) object;
|
||||
}
|
||||
if (object instanceof Block)
|
||||
{
|
||||
return new ItemStack(((Block) object).blockID, 1, -1);
|
||||
}
|
||||
if (object instanceof Item)
|
||||
{
|
||||
return new ItemStack(((Item) object).itemID, 1, -1);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static ItemStack getOuput(ProcessorType type, ItemStack stack)
|
||||
{
|
||||
if (stack == null || type == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
HashMap<Pair<Integer, Integer>, ItemStack> map = null;
|
||||
ItemStack testStack = stack.copy();
|
||||
testStack.stackSize = 1;
|
||||
switch (type)
|
||||
{
|
||||
case CRUSHER:
|
||||
map = crusherRecipes;
|
||||
break;
|
||||
case GRINDER:
|
||||
map = grinderrRecipes;
|
||||
break;
|
||||
case PRESS:
|
||||
map = pressRecipes;
|
||||
break;
|
||||
}
|
||||
if (map == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
ItemStack re = map.get(new Pair<Integer, Integer>(stack.itemID, -1));
|
||||
if (re != null)
|
||||
{
|
||||
return re;
|
||||
}
|
||||
return map.get(new Pair<Integer, Integer>(stack.itemID, stack.getItemDamage()));
|
||||
}
|
||||
|
||||
public static class oreReceipe
|
||||
{
|
||||
ItemStack input, output;
|
||||
|
||||
}
|
||||
|
||||
public static enum ProcessorType
|
||||
{
|
||||
CRUSHER(),
|
||||
GRINDER(),
|
||||
PRESS();
|
||||
}
|
||||
}
|
|
@ -1,10 +1,20 @@
|
|||
package dark.assembly.common.machine.processor;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import dark.assembly.common.machine.processor.ProcessorRecipes.ProcessorType;
|
||||
import dark.api.ProcessorRecipes;
|
||||
import dark.api.ProcessorRecipes.ProcessorType;
|
||||
import dark.core.network.PacketHandler;
|
||||
import dark.core.prefab.TileEntityMachine;
|
||||
import dark.core.prefab.TileEntityMachine.TilePacketTypes;
|
||||
import dark.core.prefab.invgui.InvChest;
|
||||
|
||||
/** Basic A -> B recipe processor machine designed mainly to handle ore blocks
|
||||
|
@ -20,6 +30,8 @@ public class TileEntityProcessor extends TileEntityMachine
|
|||
|
||||
public ProcessorType type;
|
||||
|
||||
public boolean invertPiston = false;
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
|
@ -28,29 +40,38 @@ public class TileEntityProcessor extends TileEntityMachine
|
|||
if (this.getBlockMetadata() == 0 || this.getBlockMetadata() == 1)
|
||||
{
|
||||
this.type = ProcessorType.CRUSHER;
|
||||
this.WATTS_PER_TICK = BlockProcessor.crusherWattPerTick;
|
||||
}
|
||||
|
||||
this.MAX_WATTS = this.WATTS_PER_TICK * 20;
|
||||
}
|
||||
super.updateEntity();
|
||||
if (this.running)
|
||||
{
|
||||
if (this.ticks % 5 == 0)
|
||||
if (invertPiston)
|
||||
{
|
||||
renderStage = renderStage++;
|
||||
if (renderStage >= 8)
|
||||
if (renderStage-- <= 0)
|
||||
{
|
||||
renderStage = 1;
|
||||
invertPiston = false;
|
||||
}
|
||||
}
|
||||
if (!this.worldObj.isRemote)
|
||||
else
|
||||
{
|
||||
|
||||
if (this.processingTicks++ >= this.processingTime)
|
||||
if (renderStage++ >= 8)
|
||||
{
|
||||
this.processingTicks = 0;
|
||||
this.process();
|
||||
invertPiston = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!this.worldObj.isRemote)
|
||||
{
|
||||
|
||||
if (this.processingTicks++ >= this.processingTime)
|
||||
{
|
||||
this.processingTicks = 0;
|
||||
this.process();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -75,7 +96,7 @@ public class TileEntityProcessor extends TileEntityMachine
|
|||
{
|
||||
return true;
|
||||
}
|
||||
else if (ItemStack.areItemStacksEqual(outputResult, outputStack))
|
||||
else if (outputResult.isItemEqual(outputStack))
|
||||
{
|
||||
if (Math.min(outputStack.getMaxStackSize() - outputStack.stackSize, this.getInventoryStackLimit()) >= outputResult.stackSize)
|
||||
{
|
||||
|
@ -90,7 +111,6 @@ public class TileEntityProcessor extends TileEntityMachine
|
|||
/** Processes the itemStack */
|
||||
public void process()
|
||||
{
|
||||
System.out.println("Processing stack");
|
||||
ItemStack inputSlotStack = this.getInventory().getStackInSlot(this.slotInput);
|
||||
ItemStack outputSlotStack = this.getInventory().getStackInSlot(this.slotOutput);
|
||||
if (inputSlotStack != null)
|
||||
|
@ -99,10 +119,7 @@ public class TileEntityProcessor extends TileEntityMachine
|
|||
inputSlotStack = inputSlotStack.copy();
|
||||
inputSlotStack.stackSize = 1;
|
||||
ItemStack receipeResult = ProcessorRecipes.getOuput(this.type, inputSlotStack);
|
||||
System.out.println("Input = " + inputSlotStack.toString());
|
||||
System.out.println("Output = " + (outputSlotStack == null ? "Null" : outputSlotStack.toString()));
|
||||
System.out.println("Result = " + (receipeResult == null ? "Null" : receipeResult.toString()));
|
||||
if (receipeResult != null && (outputSlotStack == null || ItemStack.areItemStacksEqual(outputSlotStack, receipeResult)))
|
||||
if (receipeResult != null && (outputSlotStack == null || outputSlotStack.isItemEqual(receipeResult)))
|
||||
{
|
||||
|
||||
ItemStack outputStack = outputSlotStack == null ? receipeResult : outputSlotStack.copy();
|
||||
|
@ -157,13 +174,12 @@ public class TileEntityProcessor extends TileEntityMachine
|
|||
{
|
||||
return new int[] { slotInput };
|
||||
}
|
||||
return new int[] { slotBatteryDrain };
|
||||
return new int[] { slotBatteryDrain, slotInput, slotOutput };
|
||||
}
|
||||
|
||||
public ForgeDirection getDirection()
|
||||
{
|
||||
int meta = this.worldObj.getBlockMetadata(xCoord, yCoord, zCoord);
|
||||
if (meta == 0)
|
||||
if (this.worldObj.getBlockMetadata(xCoord, yCoord, zCoord) == 0)
|
||||
{
|
||||
return ForgeDirection.NORTH;
|
||||
}
|
||||
|
@ -194,6 +210,40 @@ public class TileEntityProcessor extends TileEntityMachine
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendGUIPacket(EntityPlayer entity)
|
||||
{
|
||||
if (!this.worldObj.isRemote && entity instanceof EntityPlayerMP)
|
||||
{
|
||||
((EntityPlayerMP) entity).playerNetServerHandler.sendPacketToPlayer(PacketHandler.instance().getPacket(this.getChannel(), this, TilePacketTypes.GUI.name, this.processingTicks, this.processingTime, this.energyStored));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean simplePacket(String id, DataInputStream dis, EntityPlayer player)
|
||||
{
|
||||
if (!super.simplePacket(id, dis, player))
|
||||
{
|
||||
try
|
||||
{
|
||||
if (this.worldObj.isRemote)
|
||||
{
|
||||
if (id.equalsIgnoreCase(TilePacketTypes.GUI.name))
|
||||
{
|
||||
this.processingTicks = dis.readInt();
|
||||
this.processingTime = dis.readInt();
|
||||
this.setEnergyStored(dis.readFloat());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** NBT Data */
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt)
|
||||
|
|
Loading…
Reference in a new issue