Created a crusher machine
First machine in a series of machines. This is designed to be a low capacity machine with a single stack input. Larger version will be added later that can process items as fast as they are inputted. As well it will be belt based, and will not actually store the item. Instead it will process the item on the belt and does have a chance to miss the item if the belt goes too fast.
This commit is contained in:
parent
b7f158604e
commit
57f214edac
8 changed files with 631 additions and 0 deletions
BIN
models/Machines/CrusherSingleBlock.tcn
Normal file
BIN
models/Machines/CrusherSingleBlock.tcn
Normal file
Binary file not shown.
BIN
resources/assets/al/textures/models/CrusherBlock.png
Normal file
BIN
resources/assets/al/textures/models/CrusherBlock.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.3 KiB |
|
@ -19,6 +19,7 @@ import dark.assembly.client.render.RenderCraneFrame;
|
|||
import dark.assembly.client.render.RenderCrate;
|
||||
import dark.assembly.client.render.RenderDetector;
|
||||
import dark.assembly.client.render.RenderManipulator;
|
||||
import dark.assembly.client.render.RenderProcessor;
|
||||
import dark.assembly.client.render.RenderRejector;
|
||||
import dark.assembly.common.CommonProxy;
|
||||
import dark.assembly.common.armbot.TileEntityArmbot;
|
||||
|
@ -31,6 +32,7 @@ import dark.assembly.common.machine.belt.TileEntityConveyorBelt;
|
|||
import dark.assembly.common.machine.crane.TileEntityCraneController;
|
||||
import dark.assembly.common.machine.crane.TileEntityCraneRail;
|
||||
import dark.assembly.common.machine.encoder.TileEntityEncoder;
|
||||
import dark.assembly.common.machine.processor.TileEntityProcessor;
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class ClientProxy extends CommonProxy
|
||||
{
|
||||
|
@ -48,6 +50,7 @@ public class ClientProxy extends CommonProxy
|
|||
super.init();
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityConveyorBelt.class, new RenderConveyorBelt());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityRejector.class, new RenderRejector());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityProcessor.class, new RenderProcessor());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityManipulator.class, new RenderManipulator());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityCrate.class, new RenderCrate());
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityArmbot.class, new RenderArmbot());
|
||||
|
|
178
src/minecraft/dark/assembly/client/model/ModelCrusher.java
Normal file
178
src/minecraft/dark/assembly/client/model/ModelCrusher.java
Normal file
|
@ -0,0 +1,178 @@
|
|||
// Date: 9/13/2013 10:47:00 PM
|
||||
// Template version 1.1
|
||||
// Java generated by Techne
|
||||
// Keep in mind that you still need to fill in some blanks
|
||||
// - ZeuX
|
||||
|
||||
package dark.assembly.client.model;
|
||||
|
||||
import net.minecraft.client.model.ModelBase;
|
||||
import net.minecraft.client.model.ModelRenderer;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.MathHelper;
|
||||
|
||||
public class ModelCrusher extends ModelBase
|
||||
{
|
||||
//fields
|
||||
ModelRenderer base;
|
||||
ModelRenderer front;
|
||||
ModelRenderer back;
|
||||
ModelRenderer leftSide;
|
||||
ModelRenderer leftSide2;
|
||||
ModelRenderer rightSide;
|
||||
ModelRenderer rightSide2;
|
||||
ModelRenderer leftCrusher;
|
||||
ModelRenderer rightCrusher;
|
||||
ModelRenderer leftPiston;
|
||||
ModelRenderer rightPiston;
|
||||
ModelRenderer buttonA;
|
||||
ModelRenderer buttonB;
|
||||
ModelRenderer top;
|
||||
|
||||
public ModelCrusher()
|
||||
{
|
||||
textureWidth = 128;
|
||||
textureHeight = 128;
|
||||
|
||||
base = new ModelRenderer(this, 0, 110);
|
||||
base.addBox(-8F, 0F, -8F, 16, 2, 16);
|
||||
base.setRotationPoint(0F, 22F, 0F);
|
||||
base.setTextureSize(128, 128);
|
||||
base.mirror = true;
|
||||
setRotation(base, 0F, 0F, 0F);
|
||||
front = new ModelRenderer(this, 0, 30);
|
||||
front.addBox(0F, 0F, 0F, 14, 5, 2);
|
||||
front.setRotationPoint(-7F, 17F, -7F);
|
||||
front.setTextureSize(128, 128);
|
||||
front.mirror = true;
|
||||
setRotation(front, 0F, 0F, 0F);
|
||||
back = new ModelRenderer(this, 0, 50);
|
||||
back.addBox(0F, 0F, 0F, 14, 5, 2);
|
||||
back.setRotationPoint(-7F, 17F, 5F);
|
||||
back.setTextureSize(128, 128);
|
||||
back.mirror = true;
|
||||
setRotation(back, 0F, 0F, 0F);
|
||||
leftSide = new ModelRenderer(this, 104, 0);
|
||||
leftSide.addBox(0F, 0F, 0F, 2, 12, 8);
|
||||
leftSide.setRotationPoint(-7F, 10F, -4F);
|
||||
leftSide.setTextureSize(128, 128);
|
||||
leftSide.mirror = true;
|
||||
setRotation(leftSide, 0F, 0F, 0F);
|
||||
leftSide2 = new ModelRenderer(this, 104, 23);
|
||||
leftSide2.addBox(0F, 0F, 0F, 1, 11, 7);
|
||||
leftSide2.setRotationPoint(-8F, 11.33333F, -3.5F);
|
||||
leftSide2.setTextureSize(128, 128);
|
||||
leftSide2.mirror = true;
|
||||
setRotation(leftSide2, 0F, 0F, 0F);
|
||||
rightSide = new ModelRenderer(this, 80, 0);
|
||||
rightSide.addBox(0F, 0F, 0F, 2, 12, 8);
|
||||
rightSide.setRotationPoint(5F, 10F, -4F);
|
||||
rightSide.setTextureSize(128, 128);
|
||||
rightSide.mirror = true;
|
||||
setRotation(rightSide, 0F, 0F, 0F);
|
||||
rightSide2 = new ModelRenderer(this, 80, 23);
|
||||
rightSide2.addBox(0F, 0F, 0F, 1, 11, 7);
|
||||
rightSide2.setRotationPoint(7F, 11.33333F, -3.5F);
|
||||
rightSide2.setTextureSize(128, 128);
|
||||
rightSide2.mirror = true;
|
||||
setRotation(rightSide2, 0F, 0F, 0F);
|
||||
leftCrusher = new ModelRenderer(this, 104, 45);
|
||||
leftCrusher.addBox(-1F, 0F, 0F, 2, 10, 10);
|
||||
leftCrusher.setRotationPoint(-3F, 11F, -5F);
|
||||
leftCrusher.setTextureSize(128, 128);
|
||||
leftCrusher.mirror = true;
|
||||
setRotation(leftCrusher, 0F, 0F, 0F);
|
||||
rightCrusher = new ModelRenderer(this, 77, 45);
|
||||
rightCrusher.addBox(1F, 0F, 0F, 2, 10, 10);
|
||||
rightCrusher.setRotationPoint(1F, 11F, -5F);
|
||||
rightCrusher.setTextureSize(128, 128);
|
||||
rightCrusher.mirror = true;
|
||||
setRotation(rightCrusher, 0F, 0F, 0F);
|
||||
leftPiston = new ModelRenderer(this, 104, 68);
|
||||
leftPiston.addBox(0F, 0F, 0F, 4, 4, 4);
|
||||
leftPiston.setRotationPoint(-6F, 14F, -2F);
|
||||
leftPiston.setTextureSize(128, 128);
|
||||
leftPiston.mirror = true;
|
||||
setRotation(leftPiston, 0F, 0F, 0F);
|
||||
rightPiston = new ModelRenderer(this, 80, 68);
|
||||
rightPiston.addBox(-2F, 0F, 0F, 4, 4, 4);
|
||||
rightPiston.setRotationPoint(4F, 14F, -2F);
|
||||
rightPiston.setTextureSize(128, 128);
|
||||
rightPiston.mirror = true;
|
||||
setRotation(rightPiston, 0F, 0F, 0F);
|
||||
buttonA = new ModelRenderer(this, 0, 20);
|
||||
buttonA.addBox(0F, 0F, 0F, 3, 2, 1);
|
||||
buttonA.setRotationPoint(5F, 14F, 4F);
|
||||
buttonA.setTextureSize(128, 128);
|
||||
buttonA.mirror = true;
|
||||
setRotation(buttonA, 0F, 0F, 0F);
|
||||
buttonB = new ModelRenderer(this, 0, 25);
|
||||
buttonB.addBox(0F, 0F, 0F, 3, 2, 1);
|
||||
buttonB.setRotationPoint(-8F, 14F, -5F);
|
||||
buttonB.setTextureSize(128, 128);
|
||||
buttonB.mirror = true;
|
||||
setRotation(buttonB, 0F, 0F, 0F);
|
||||
top = new ModelRenderer(this, 0, 68);
|
||||
top.addBox(0F, 0F, 0F, 12, 2, 6);
|
||||
top.setRotationPoint(-6F, 9F, -3F);
|
||||
top.setTextureSize(128, 128);
|
||||
top.mirror = true;
|
||||
setRotation(top, 0F, 0F, 0F);
|
||||
}
|
||||
|
||||
public void renderBody(float f5)
|
||||
{
|
||||
base.render(f5);
|
||||
front.render(f5);
|
||||
back.render(f5);
|
||||
leftSide.render(f5);
|
||||
leftSide2.render(f5);
|
||||
rightSide.render(f5);
|
||||
rightSide2.render(f5);
|
||||
buttonA.render(f5);
|
||||
buttonB.render(f5);
|
||||
top.render(f5);
|
||||
leftPiston.render(f5);
|
||||
rightPiston.render(f5);
|
||||
}
|
||||
|
||||
public void renderPiston(float f5, int pos)
|
||||
{
|
||||
leftCrusher.setRotationPoint(-3F, 11F, -5F);
|
||||
rightCrusher.setRotationPoint(1F, 11F, -5F);
|
||||
|
||||
if (pos > 8)
|
||||
{
|
||||
pos = 8;
|
||||
}
|
||||
if (pos < 0)
|
||||
{
|
||||
pos = 0;
|
||||
}
|
||||
int delta = 0;
|
||||
switch (pos / 2)
|
||||
{
|
||||
case 1:
|
||||
delta = 1;
|
||||
break;
|
||||
case 2:
|
||||
delta = 2;
|
||||
break;
|
||||
default:
|
||||
delta = 0;
|
||||
break;
|
||||
}
|
||||
leftCrusher.setRotationPoint(-3F + delta, 11F, -5F);
|
||||
rightCrusher.setRotationPoint(1F - delta, 11F, -5F);
|
||||
leftCrusher.render(f5);
|
||||
rightCrusher.render(f5);
|
||||
}
|
||||
|
||||
private void setRotation(ModelRenderer model, float x, float y, float z)
|
||||
{
|
||||
model.rotateAngleX = x;
|
||||
model.rotateAngleY = y;
|
||||
model.rotateAngleZ = z;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package dark.assembly.client.render;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
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)
|
||||
public class RenderProcessor extends RenderTileMachine
|
||||
{
|
||||
private ModelCrusher model = new ModelCrusher();
|
||||
|
||||
private void renderAModelAt(TileEntityProcessor tileEntity, double x, double y, double z, float f)
|
||||
{
|
||||
func_110628_a(this.getTexture(tileEntity.blockType.blockID, tileEntity.blockMetadata));
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);
|
||||
GL11.glScalef(1.0F, -1F, -1F);
|
||||
|
||||
if (tileEntity.getDirection() == ForgeDirection.EAST)
|
||||
{
|
||||
GL11.glRotatef(90f, 0f, 1f, 0f);
|
||||
}
|
||||
if (tileEntity.blockMetadata == 0 || tileEntity.blockMetadata == 1)
|
||||
{
|
||||
model.renderBody(0.0625F);
|
||||
model.renderPiston(0.0625F, tileEntity.renderStage);
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tileEntity, double var2, double var4, double var6, float var8)
|
||||
{
|
||||
if (tileEntity instanceof TileEntityProcessor)
|
||||
this.renderAModelAt((TileEntityProcessor) tileEntity, var2, var4, var6, var8);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getTexture(int block, int meta)
|
||||
{
|
||||
return new ResourceLocation(AssemblyLine.instance.DOMAIN, AssemblyLine.MODEL_DIRECTORY + "CrusherBlock.png");
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,124 @@
|
|||
package dark.assembly.common.machine.processor;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.Configuration;
|
||||
import universalelectricity.core.UniversalElectricity;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import dark.assembly.common.AssemblyLine;
|
||||
import dark.assembly.common.TabAssemblyLine;
|
||||
import dark.assembly.common.machine.processor.ProcessorRecipes.ProcessorType;
|
||||
import dark.core.common.DarkMain;
|
||||
import dark.core.prefab.BlockMachine;
|
||||
import dark.core.prefab.IExtraObjectInfo;
|
||||
import dark.core.prefab.helpers.Pair;
|
||||
|
||||
public class BlockProcessor extends BlockMachine implements IExtraObjectInfo
|
||||
{
|
||||
|
||||
public BlockProcessor(int blockID)
|
||||
{
|
||||
super("OreProcessor", AssemblyLine.CONFIGURATION, blockID, UniversalElectricity.machine);
|
||||
this.setCreativeTab(TabAssemblyLine.INSTANCE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onMachineActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
//TODO activate GUI, and if GS is installed do user lock protection
|
||||
//Maybe later add support for button activation to cause animation of the crusher to activate
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onSneakMachineActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
//Open machine calibration menu
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onUseWrench(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
if (meta == 0)
|
||||
{
|
||||
world.setBlockMetadataWithNotify(x, y, z, 1, 3);
|
||||
return true;
|
||||
}
|
||||
if (meta == 1)
|
||||
{
|
||||
world.setBlockMetadataWithNotify(x, y, z, 0, 3);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IconRegister iconReg)
|
||||
{
|
||||
if (this.blockIcon == null)
|
||||
{
|
||||
this.blockIcon = iconReg.registerIcon(DarkMain.getInstance().PREFIX + "machine");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Icon getIcon(int par1, int par2)
|
||||
{
|
||||
return this.blockIcon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getTileEntities(int blockID, Set<Pair<String, Class<? extends TileEntity>>> list)
|
||||
{
|
||||
list.add(new Pair<String, Class<? extends TileEntity>>("ALProcessor", TileEntityProcessor.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity(World world, int metadata)
|
||||
{
|
||||
if (metadata == 0 || metadata == 1)
|
||||
{
|
||||
return new TileEntityProcessor(ProcessorType.CRUSHER);
|
||||
}
|
||||
return super.createTileEntity(world, metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasExtraConfigs()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadExtraConfigs(Configuration config)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadRecipes()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadOreNames()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,100 @@
|
|||
package dark.assembly.common.machine.processor;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ProcessorRecipes
|
||||
{
|
||||
public static HashMap<ItemStack, ItemStack> crusherRecipes = new HashMap();
|
||||
public static HashMap<ItemStack, ItemStack> grinderrRecipes = new HashMap();
|
||||
public static HashMap<ItemStack, ItemStack> pressRecipes = new HashMap();
|
||||
|
||||
static
|
||||
{
|
||||
createABRecipe(ProcessorType.CRUSHER, Block.stone, Block.cobblestone);
|
||||
}
|
||||
|
||||
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<ItemStack, 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(input, output);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static ItemStack convert(Object object)
|
||||
{
|
||||
if (object instanceof ItemStack)
|
||||
{
|
||||
return (ItemStack) object;
|
||||
}
|
||||
if (object instanceof Block)
|
||||
{
|
||||
return new ItemStack((Block) object, 1);
|
||||
}
|
||||
if (object instanceof Item)
|
||||
{
|
||||
return new ItemStack((Item) object, 1);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static ItemStack getOuput(ProcessorType type, ItemStack stack)
|
||||
{
|
||||
if (stack == null || type == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
HashMap<ItemStack, ItemStack> map = null;
|
||||
switch (type)
|
||||
{
|
||||
case CRUSHER:
|
||||
map = crusherRecipes;
|
||||
break;
|
||||
case GRINDER:
|
||||
map = grinderrRecipes;
|
||||
break;
|
||||
case PRESS:
|
||||
map = pressRecipes;
|
||||
break;
|
||||
}
|
||||
return map == null ? null : map.get(stack);
|
||||
}
|
||||
|
||||
public static class oreReceipe
|
||||
{
|
||||
ItemStack input, output;
|
||||
|
||||
}
|
||||
|
||||
public static enum ProcessorType
|
||||
{
|
||||
CRUSHER(),
|
||||
GRINDER(),
|
||||
PRESS();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,170 @@
|
|||
package dark.assembly.common.machine.processor;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import dark.assembly.common.machine.processor.ProcessorRecipes.ProcessorType;
|
||||
import dark.core.interfaces.IInvBox;
|
||||
import dark.core.prefab.TileEntityMachine;
|
||||
import dark.core.prefab.invgui.InvChest;
|
||||
|
||||
/** Basic A -> B recipe processor machine designed mainly to handle ore blocks
|
||||
*
|
||||
* @author DarkGuardsman */
|
||||
public class TileEntityProcessor extends TileEntityMachine
|
||||
{
|
||||
private int slotInput = 0, slotOutput = 1, slotBatteryCharge = 2, slotBatteryDrain = 3;
|
||||
|
||||
private int processingTicks = 0;
|
||||
private int processingTime = 100;
|
||||
public int renderStage = 1;
|
||||
|
||||
public ProcessorType type;
|
||||
|
||||
public TileEntityProcessor(ProcessorType type)
|
||||
{
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
super.updateEntity();
|
||||
if (this.running)
|
||||
{
|
||||
if (this.ticks % 5 == 0)
|
||||
{
|
||||
renderStage = renderStage++;
|
||||
if (renderStage >= 8)
|
||||
{
|
||||
renderStage = 1;
|
||||
}
|
||||
}
|
||||
if (!this.worldObj.isRemote)
|
||||
{
|
||||
|
||||
if (this.processingTicks++ >= this.processingTime)
|
||||
{
|
||||
this.processingTicks = 0;
|
||||
this.process();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRun()
|
||||
{
|
||||
return super.canRun() && this.canProcess();
|
||||
}
|
||||
|
||||
/** Can the machine process the itemStack */
|
||||
public boolean canProcess()
|
||||
{
|
||||
ItemStack processResult = ProcessorRecipes.getOuput(this.type, this.getInventory().getStackInSlot(this.slotInput));
|
||||
ItemStack outputStack = this.getInventory().getStackInSlot(this.slotOutput);
|
||||
if (processResult != null)
|
||||
{
|
||||
if (outputStack == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (outputStack.equals(processResult))
|
||||
{
|
||||
if (Math.min(outputStack.getMaxStackSize() - outputStack.stackSize, this.getInventoryStackLimit()) >= processResult.stackSize)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Processes the itemStack */
|
||||
public void process()
|
||||
{
|
||||
ItemStack output = ProcessorRecipes.getOuput(this.type, this.getInventory().getStackInSlot(this.slotInput));
|
||||
ItemStack outputSlot = this.getInventory().getStackInSlot(this.slotOutput);
|
||||
if (output != null && outputSlot != null && output.equals(outputSlot))
|
||||
{
|
||||
ItemStack outputStack = outputSlot.copy();
|
||||
outputStack.stackSize += outputSlot.stackSize;
|
||||
this.getInventory().decrStackSize(this.slotInput, 1);
|
||||
this.getInventory().setInventorySlotContents(this.slotOutput, outputStack);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInvBox getInventory()
|
||||
{
|
||||
if (inventory == null)
|
||||
{
|
||||
inventory = new InvChest(this, 4);
|
||||
}
|
||||
return inventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canStore(ItemStack stack, int slot, ForgeDirection side)
|
||||
{
|
||||
if (slotInput == slot && ProcessorRecipes.getOuput(this.type, stack) != null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (slotBatteryDrain == slot && this.isBattery(stack))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRemove(ItemStack stack, int slot, ForgeDirection side)
|
||||
{
|
||||
return slot != slotInput;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getAccessibleSlotsFromSide(int side)
|
||||
{
|
||||
if (side == ForgeDirection.DOWN.ordinal())
|
||||
{
|
||||
return new int[] { slotOutput };
|
||||
}
|
||||
if (side == ForgeDirection.UP.ordinal())
|
||||
{
|
||||
return new int[] { slotInput };
|
||||
}
|
||||
return new int[] { slotBatteryDrain };
|
||||
}
|
||||
|
||||
public ForgeDirection getDirection()
|
||||
{
|
||||
int meta = this.worldObj.getBlockMetadata(xCoord, yCoord, zCoord);
|
||||
if (meta == 0)
|
||||
{
|
||||
return ForgeDirection.NORTH;
|
||||
}
|
||||
return ForgeDirection.EAST;
|
||||
}
|
||||
|
||||
/** NBT Data */
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt)
|
||||
{
|
||||
super.readFromNBT(nbt);
|
||||
this.processingTicks = nbt.getInteger("processingTicks");
|
||||
this.renderStage = nbt.getInteger("renderStage");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound nbt)
|
||||
{
|
||||
super.writeToNBT(nbt);
|
||||
nbt.setInteger("processingTicks", this.processingTicks);
|
||||
nbt.setInteger("renderStage", this.renderStage);
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue