got the salvaging system working
This commit is contained in:
parent
c4c9922aa8
commit
0cac9216b8
5 changed files with 112 additions and 56 deletions
|
@ -171,8 +171,8 @@ public class ModelGrinder extends ModelBase
|
||||||
//Set new rotation angle
|
//Set new rotation angle
|
||||||
for (int i = 0; i < 6; i++)
|
for (int i = 0; i < 6; i++)
|
||||||
{
|
{
|
||||||
topDiskSet[i].offsetX += rotation;
|
topDiskSet[i].rotateAngleX += rotation;
|
||||||
bottomDiskSet[i].offsetX -= rotation;
|
bottomDiskSet[i].rotateAngleX -= rotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
//render
|
//render
|
||||||
|
@ -191,22 +191,22 @@ public class ModelGrinder extends ModelBase
|
||||||
{
|
{
|
||||||
if (i == 0 || i % 2 == 0)
|
if (i == 0 || i % 2 == 0)
|
||||||
{
|
{
|
||||||
topDiskSet[i].offsetX = 0.7853982F;
|
topDiskSet[i].rotateAngleX = 0.7853982F;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
topDiskSet[i].offsetX = 0F;
|
topDiskSet[i].rotateAngleX = 0F;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int i = 0; i < bottomDiskSet.length; i++)
|
for (int i = 0; i < bottomDiskSet.length; i++)
|
||||||
{
|
{
|
||||||
if (i != 0 && i % 2 != 0)
|
if (i != 0 && i % 2 != 0)
|
||||||
{
|
{
|
||||||
bottomDiskSet[i].offsetX = 0.7853982F;
|
bottomDiskSet[i].rotateAngleX = 0.7853982F;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bottomDiskSet[i].offsetX = 0F;
|
bottomDiskSet[i].rotateAngleX = 0F;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,21 +51,22 @@ public class RenderProcessor extends RenderTileMachine
|
||||||
GL11.glRotatef(270f, 0f, 1f, 0f);
|
GL11.glRotatef(270f, 0f, 1f, 0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tileEntity.blockMetadata >= 0 && tileEntity.blockMetadata <= 3)
|
int g = tileEntity.blockMetadata / 4;
|
||||||
|
if (g == 0)
|
||||||
{
|
{
|
||||||
crusherModel.renderBody(0.0625F);
|
crusherModel.renderBody(0.0625F);
|
||||||
crusherModel.renderPiston(0.0625F, tileEntity.renderStage);
|
crusherModel.renderPiston(0.0625F, tileEntity.renderStage);
|
||||||
}
|
}
|
||||||
else if (tileEntity.blockMetadata >= 4 && tileEntity.blockMetadata <= 7)
|
else if (g == 1)
|
||||||
{
|
{
|
||||||
grinderModel.renderBody(0.0625F);
|
grinderModel.renderBody(0.0625F);
|
||||||
grinderModel.renderRotation(0.0625F, tileEntity.renderStage);
|
grinderModel.renderRotation(0.0625F, tileEntity.renderStage);
|
||||||
}
|
}
|
||||||
else if (tileEntity.blockMetadata >= 8 && tileEntity.blockMetadata <= 11)
|
else if (g == 2)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (tileEntity.blockMetadata >= 12 && tileEntity.blockMetadata <= 15)
|
else if (g == 3)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -83,7 +84,16 @@ public class RenderProcessor extends RenderTileMachine
|
||||||
@Override
|
@Override
|
||||||
public ResourceLocation getTexture(int block, int meta)
|
public ResourceLocation getTexture(int block, int meta)
|
||||||
{
|
{
|
||||||
return new ResourceLocation(AssemblyLine.instance.DOMAIN, AssemblyLine.MODEL_DIRECTORY + "CrusherBlock.png");
|
int g = meta / 4;
|
||||||
}
|
if (g == 0)
|
||||||
|
{
|
||||||
|
return new ResourceLocation(AssemblyLine.instance.DOMAIN, AssemblyLine.MODEL_DIRECTORY + "CrusherBlock.png");
|
||||||
|
}
|
||||||
|
else if (g == 1)
|
||||||
|
{
|
||||||
|
return new ResourceLocation(AssemblyLine.instance.DOMAIN, AssemblyLine.MODEL_DIRECTORY + "GrinderBlock.png");
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -41,21 +41,21 @@ public class BlockProcessor extends BlockMachine implements IExtraObjectInfo
|
||||||
@Override
|
@Override
|
||||||
public boolean onMachineActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ)
|
public boolean onMachineActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ)
|
||||||
{
|
{
|
||||||
if (!world.isRemote)
|
if (entityPlayer != null)
|
||||||
{
|
{
|
||||||
entityPlayer.openGui(AssemblyLine.instance, CommonProxy.GUI_CRUSHER, world, x, y, z);
|
if (world.isRemote)
|
||||||
return true;
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
entityPlayer.openGui(AssemblyLine.instance, CommonProxy.GUI_CRUSHER, world, x, y, z);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
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
|
@Override
|
||||||
public boolean onUseWrench(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ)
|
public boolean onUseWrench(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ)
|
||||||
{
|
{
|
||||||
|
@ -76,7 +76,7 @@ public class BlockProcessor extends BlockMachine implements IExtraObjectInfo
|
||||||
@Override
|
@Override
|
||||||
public void getTileEntities(int blockID, Set<Pair<String, Class<? extends TileEntity>>> list)
|
public void getTileEntities(int blockID, Set<Pair<String, Class<? extends TileEntity>>> list)
|
||||||
{
|
{
|
||||||
list.add(new Pair<String, Class<? extends TileEntity>>("ALProcessor", TileEntityProcessor.class));
|
list.add(new Pair<String, Class<? extends TileEntity>>("ALOreProcessor", TileEntityProcessor.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -128,7 +128,7 @@ public class ContainerProcessor extends Container
|
||||||
}
|
}
|
||||||
else if (slotID != 1 && slotID != 0)
|
else if (slotID != 1 && slotID != 0)
|
||||||
{
|
{
|
||||||
if (ProcessorRecipes.getOuput(tileEntity.type, slotStack) != null)
|
if (ProcessorRecipes.getOuput(tileEntity.getProcessorData().type, slotStack) != null)
|
||||||
{
|
{
|
||||||
if (!this.mergeItemStack(slotStack, tileEntity.slotInput, 1, false))
|
if (!this.mergeItemStack(slotStack, tileEntity.slotInput, 1, false))
|
||||||
{
|
{
|
||||||
|
|
|
@ -27,23 +27,29 @@ public class TileEntityProcessor extends TileEntityMachine
|
||||||
public int processingTime = 100;
|
public int processingTime = 100;
|
||||||
public int renderStage = 1;
|
public int renderStage = 1;
|
||||||
|
|
||||||
public ProcessorType type;
|
public ProcessorData processorData;
|
||||||
|
|
||||||
public boolean invertPiston = false;
|
public boolean invertPiston = false;
|
||||||
|
protected ItemStack[] outputBuffer;
|
||||||
|
|
||||||
|
public ProcessorData getProcessorData()
|
||||||
|
{
|
||||||
|
if (this.processorData == null)
|
||||||
|
{
|
||||||
|
int g = this.worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord) / 4;
|
||||||
|
this.processorData = ProcessorData.values()[g];
|
||||||
|
this.WATTS_PER_TICK = processorData.wattPerTick;
|
||||||
|
this.MAX_WATTS = this.WATTS_PER_TICK * 20;
|
||||||
|
|
||||||
|
this.processingTime = processorData.processingTicks;
|
||||||
|
}
|
||||||
|
return processorData;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateEntity()
|
public void updateEntity()
|
||||||
{
|
{
|
||||||
if (this.type == null)
|
this.getProcessorData();
|
||||||
{
|
|
||||||
int g = this.worldObj.getBlockMetadata(this.xCoord, this.yCoord, this.zCoord) / 4;
|
|
||||||
ProcessorData data = ProcessorData.values()[g];
|
|
||||||
|
|
||||||
this.WATTS_PER_TICK = data.wattPerTick;
|
|
||||||
this.MAX_WATTS = this.WATTS_PER_TICK * 20;
|
|
||||||
|
|
||||||
this.processingTicks = data.processingTicks;
|
|
||||||
}
|
|
||||||
super.updateEntity();
|
super.updateEntity();
|
||||||
if (this.running)
|
if (this.running)
|
||||||
{
|
{
|
||||||
|
@ -51,11 +57,52 @@ public class TileEntityProcessor extends TileEntityMachine
|
||||||
|
|
||||||
if (!this.worldObj.isRemote)
|
if (!this.worldObj.isRemote)
|
||||||
{
|
{
|
||||||
|
if (this.outputBuffer != null)
|
||||||
if (this.processingTicks++ >= this.processingTime)
|
{
|
||||||
|
int nullCount = 0;
|
||||||
|
for (int i = 0; i < outputBuffer.length; i++)
|
||||||
|
{
|
||||||
|
ItemStack outputStack = this.getInventory().getStackInSlot(this.slotOutput);
|
||||||
|
|
||||||
|
if (outputBuffer[i] == null)
|
||||||
|
{
|
||||||
|
nullCount += 1;
|
||||||
|
}
|
||||||
|
else if (outputStack == null)
|
||||||
|
{
|
||||||
|
this.getInventory().setInventorySlotContents(this.slotOutput, outputBuffer[i].copy());
|
||||||
|
outputBuffer[i] = null;
|
||||||
|
}
|
||||||
|
else if (outputBuffer[i] != null && outputBuffer[i].isItemEqual(outputStack))
|
||||||
|
{
|
||||||
|
ItemStack outStack = outputStack.copy();
|
||||||
|
int room = Math.min(outputStack.getMaxStackSize() - outputStack.stackSize, this.getInventoryStackLimit());
|
||||||
|
if (room >= outputBuffer[i].stackSize)
|
||||||
|
{
|
||||||
|
|
||||||
|
outStack.stackSize += outputBuffer[i].stackSize;
|
||||||
|
outputBuffer[i] = null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int extract = outputBuffer[i].stackSize - (outputBuffer[i].stackSize - room);
|
||||||
|
outputBuffer[i].stackSize -= extract;
|
||||||
|
outStack.stackSize += extract;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
this.getInventory().setInventorySlotContents(this.slotOutput, outStack);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (nullCount >= outputBuffer.length)
|
||||||
|
{
|
||||||
|
outputBuffer = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (outputBuffer == null && this.processingTicks++ >= this.processingTime)
|
||||||
{
|
{
|
||||||
this.processingTicks = 0;
|
|
||||||
this.process();
|
this.process();
|
||||||
|
this.processingTicks = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -63,7 +110,7 @@ public class TileEntityProcessor extends TileEntityMachine
|
||||||
|
|
||||||
public void doAnimation()
|
public void doAnimation()
|
||||||
{
|
{
|
||||||
if (this.type == ProcessorType.CRUSHER || this.type == ProcessorType.PRESS)
|
if (this.getProcessorData().type == ProcessorType.CRUSHER || this.getProcessorData().type == ProcessorType.PRESS)
|
||||||
{
|
{
|
||||||
if (invertPiston)
|
if (invertPiston)
|
||||||
{
|
{
|
||||||
|
@ -104,18 +151,24 @@ public class TileEntityProcessor extends TileEntityMachine
|
||||||
{
|
{
|
||||||
inputStack = inputStack.copy();
|
inputStack = inputStack.copy();
|
||||||
inputStack.stackSize = 1;
|
inputStack.stackSize = 1;
|
||||||
ItemStack outputResult = ProcessorRecipes.getOuput(this.type, inputStack);
|
ItemStack[] outputResult = ProcessorRecipes.getOuput(this.getProcessorData().type, inputStack);
|
||||||
if (outputResult != null)
|
if (outputResult != null)
|
||||||
{
|
{
|
||||||
if (outputStack == null)
|
if (outputStack == null)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (outputResult.isItemEqual(outputStack))
|
else
|
||||||
{
|
{
|
||||||
if (Math.min(outputStack.getMaxStackSize() - outputStack.stackSize, this.getInventoryStackLimit()) >= outputResult.stackSize)
|
for (int i = 0; i < outputResult.length; i++)
|
||||||
{
|
{
|
||||||
return true;
|
if (outputResult[i] != null && outputResult[i].isItemEqual(outputStack))
|
||||||
|
{
|
||||||
|
if (Math.min(outputStack.getMaxStackSize() - outputStack.stackSize, this.getInventoryStackLimit()) >= outputResult[i].stackSize)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -127,23 +180,16 @@ public class TileEntityProcessor extends TileEntityMachine
|
||||||
public void process()
|
public void process()
|
||||||
{
|
{
|
||||||
ItemStack inputSlotStack = this.getInventory().getStackInSlot(this.slotInput);
|
ItemStack inputSlotStack = this.getInventory().getStackInSlot(this.slotInput);
|
||||||
ItemStack outputSlotStack = this.getInventory().getStackInSlot(this.slotOutput);
|
|
||||||
if (inputSlotStack != null)
|
if (inputSlotStack != null)
|
||||||
{
|
{
|
||||||
|
|
||||||
inputSlotStack = inputSlotStack.copy();
|
inputSlotStack = inputSlotStack.copy();
|
||||||
inputSlotStack.stackSize = 1;
|
inputSlotStack.stackSize = 1;
|
||||||
ItemStack receipeResult = ProcessorRecipes.getOuput(this.type, inputSlotStack);
|
ItemStack[] receipeResult = ProcessorRecipes.getOuput(this.getProcessorData().type, inputSlotStack);
|
||||||
if (receipeResult != null && (outputSlotStack == null || outputSlotStack.isItemEqual(receipeResult)))
|
if (receipeResult != null && this.outputBuffer == null)
|
||||||
{
|
{
|
||||||
|
|
||||||
ItemStack outputStack = outputSlotStack == null ? receipeResult.copy() : outputSlotStack.copy();
|
|
||||||
if (outputSlotStack != null)
|
|
||||||
{
|
|
||||||
outputStack.stackSize += receipeResult.stackSize;
|
|
||||||
}
|
|
||||||
this.getInventory().decrStackSize(this.slotInput, 1);
|
this.getInventory().decrStackSize(this.slotInput, 1);
|
||||||
this.getInventory().setInventorySlotContents(this.slotOutput, outputStack);
|
this.outputBuffer = receipeResult;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -161,7 +207,7 @@ public class TileEntityProcessor extends TileEntityMachine
|
||||||
@Override
|
@Override
|
||||||
public boolean canStore(ItemStack stack, int slot, ForgeDirection side)
|
public boolean canStore(ItemStack stack, int slot, ForgeDirection side)
|
||||||
{
|
{
|
||||||
if (slotInput == slot && ProcessorRecipes.getOuput(this.type, stack) != null)
|
if (slotInput == slot && ProcessorRecipes.getOuput(this.getProcessorData().type, stack) != null)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -204,9 +250,9 @@ public class TileEntityProcessor extends TileEntityMachine
|
||||||
@Override
|
@Override
|
||||||
public String getInvName()
|
public String getInvName()
|
||||||
{
|
{
|
||||||
if (this.type != null)
|
if (this.getProcessorData() != null)
|
||||||
{
|
{
|
||||||
return type.unlocalizedContainerName;
|
return "gui." + getProcessorData().unlocalizedName + ".name";
|
||||||
}
|
}
|
||||||
return "gui.processor.name";
|
return "gui.processor.name";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue