Fixed the centrifuge, still needs some testing.
This commit is contained in:
parent
4746968a04
commit
f49b8c27c2
2 changed files with 47 additions and 32 deletions
|
@ -10,7 +10,6 @@ import net.minecraft.network.Packet;
|
|||
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
||||
import techreborn.api.CentrifugeRecipie;
|
||||
import techreborn.api.TechRebornAPI;
|
||||
import techreborn.packets.PacketHandler;
|
||||
import techreborn.util.Inventory;
|
||||
import techreborn.util.ItemUtils;
|
||||
|
||||
|
@ -78,7 +77,6 @@ public class TileCentrifuge extends TileMachineBase implements IInventory {
|
|||
if(getStackInSlot(0) != null && ItemUtils.isItemEqual(getStackInSlot(0), currentRecipe.getInputItem(), true, true)){
|
||||
if(energy.useEnergy(5)){
|
||||
tickTime ++;
|
||||
syncWithAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -94,19 +92,19 @@ public class TileCentrifuge extends TileMachineBase implements IInventory {
|
|||
}
|
||||
}
|
||||
if(!isRunning && currentRecipe != null){
|
||||
if(areOutputsEqual() || areOutputsEmpty() && !areAnyOutputsFull()){
|
||||
if(areOutputsEqual() || !areAnyOutputsFull()){
|
||||
if(getStackInSlot(0) != null && currentRecipe.getInputItem().stackSize <= getStackInSlot(0).stackSize){
|
||||
if(energy.canUseEnergy(euTick)){
|
||||
decrStackSize(0, currentRecipe.getInputItem().stackSize);
|
||||
hasTakenItem = true;
|
||||
tickTime = 0;
|
||||
isRunning = true;
|
||||
syncWithAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
syncWithAll();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -114,16 +112,20 @@ public class TileCentrifuge extends TileMachineBase implements IInventory {
|
|||
if(currentRecipe == null){
|
||||
return false;
|
||||
}
|
||||
if(ItemUtils.isItemEqual(getOutputItemStack(1), currentRecipe.getOutput1(), false, true)){
|
||||
if(ItemUtils.isItemEqual(getOutputItemStack(2), currentRecipe.getOutput2(), false, true)){
|
||||
if(ItemUtils.isItemEqual(getOutputItemStack(3), currentRecipe.getOutput3(), false, true)){
|
||||
if(ItemUtils.isItemEqual(getOutputItemStack(4), currentRecipe.getOutput4(), false, true)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
boolean boo = false;
|
||||
if(currentRecipe.getOutput1() != null && ItemUtils.isItemEqual(getOutputItemStack(1), currentRecipe.getOutput1(), false, true)){
|
||||
boo = true;
|
||||
}
|
||||
return false;
|
||||
if(currentRecipe.getOutput2() != null && ItemUtils.isItemEqual(getOutputItemStack(2), currentRecipe.getOutput2(), false, true)){
|
||||
boo = true;
|
||||
}
|
||||
if(currentRecipe.getOutput3() != null && ItemUtils.isItemEqual(getOutputItemStack(3), currentRecipe.getOutput3(), false, true)){
|
||||
boo = true;
|
||||
}
|
||||
if(currentRecipe.getOutput4() != null && ItemUtils.isItemEqual(getOutputItemStack(4), currentRecipe.getOutput4(), false, true)){
|
||||
boo = true;
|
||||
}
|
||||
return boo;
|
||||
}
|
||||
|
||||
public boolean areOutputsEmpty(){
|
||||
|
@ -151,6 +153,12 @@ public class TileCentrifuge extends TileMachineBase implements IInventory {
|
|||
}
|
||||
|
||||
public void increacseItemStack(int slot, int amount) {
|
||||
if(getOutputItemStack(slot) == null){
|
||||
return;
|
||||
}
|
||||
if(getOutputItemStack(slot).getItem() == null){
|
||||
return;
|
||||
}
|
||||
decrStackSize(slot + 1, -amount);
|
||||
}
|
||||
|
||||
|
@ -158,6 +166,9 @@ public class TileCentrifuge extends TileMachineBase implements IInventory {
|
|||
if(stack == null){
|
||||
return;
|
||||
}
|
||||
if(stack.getItem() == null){
|
||||
return;
|
||||
}
|
||||
setInventorySlotContents(slot + 1, stack);
|
||||
}
|
||||
|
||||
|
@ -243,7 +254,6 @@ public class TileCentrifuge extends TileMachineBase implements IInventory {
|
|||
|
||||
@Override
|
||||
public void openInventory() {
|
||||
syncAllWithAll();
|
||||
inventory.openInventory();
|
||||
}
|
||||
|
||||
|
@ -273,24 +283,6 @@ public class TileCentrifuge extends TileMachineBase implements IInventory {
|
|||
return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, nbtTag);
|
||||
}
|
||||
|
||||
public Packet getDescriptionPacketWithOutInv() {
|
||||
NBTTagCompound nbtTag = new NBTTagCompound();
|
||||
writeUpdateToNBT(nbtTag);
|
||||
return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, nbtTag);
|
||||
}
|
||||
|
||||
public void syncWithAll() {
|
||||
if (!worldObj.isRemote) {
|
||||
PacketHandler.sendPacketToAllPlayers(getDescriptionPacketWithOutInv(), worldObj);
|
||||
}
|
||||
}
|
||||
|
||||
public void syncAllWithAll() {
|
||||
if (!worldObj.isRemote) {
|
||||
PacketHandler.sendPacketToAllPlayers(getDescriptionPacket(), worldObj);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) {
|
||||
worldObj.markBlockRangeForRenderUpdate(xCoord, yCoord, zCoord, xCoord, yCoord, zCoord);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue