Revert solderer changes
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
package refinedstorage.tile;
|
||||
package refinedstorage.tile.solderer;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.inventory.Container;
|
||||
@@ -11,26 +11,18 @@ import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.wrapper.CombinedInvWrapper;
|
||||
import refinedstorage.RefinedStorageItems;
|
||||
import refinedstorage.RefinedStorageUtils;
|
||||
import refinedstorage.api.solderer.ISoldererRecipe;
|
||||
import refinedstorage.api.solderer.SoldererRegistry;
|
||||
import refinedstorage.container.ContainerSolderer;
|
||||
import refinedstorage.inventory.BasicItemHandler;
|
||||
import refinedstorage.inventory.BasicItemValidator;
|
||||
import refinedstorage.inventory.SoldererItemHandler;
|
||||
import refinedstorage.item.ItemUpgrade;
|
||||
import refinedstorage.tile.TileMachine;
|
||||
|
||||
public class TileSolderer extends TileMachine {
|
||||
public static final String NBT_WORKING = "Working";
|
||||
public static final String NBT_PROGRESS = "Progress";
|
||||
|
||||
private BasicItemHandler items = new BasicItemHandler(4, this) {
|
||||
@Override
|
||||
protected void onContentsChanged(int slot) {
|
||||
super.onContentsChanged(slot);
|
||||
|
||||
refresh();
|
||||
}
|
||||
};
|
||||
private BasicItemHandler items = new BasicItemHandler(4, this);
|
||||
private BasicItemHandler upgrades = new BasicItemHandler(4, this, new BasicItemValidator(RefinedStorageItems.UPGRADE, ItemUpgrade.TYPE_SPEED));
|
||||
private SoldererItemHandler[] itemsFacade = new SoldererItemHandler[EnumFacing.values().length];
|
||||
|
||||
@@ -47,33 +39,11 @@ public class TileSolderer extends TileMachine {
|
||||
|
||||
@Override
|
||||
public void updateMachine() {
|
||||
if (working) {
|
||||
progress += 1 + RefinedStorageUtils.getUpgradeCount(upgrades, ItemUpgrade.TYPE_SPEED);
|
||||
|
||||
if (progress >= recipe.getDuration()) {
|
||||
ISoldererRecipe oldRecipe = recipe;
|
||||
|
||||
if (items.getStackInSlot(3) != null) {
|
||||
items.getStackInSlot(3).stackSize += recipe.getResult().stackSize;
|
||||
} else {
|
||||
items.setStackInSlot(3, recipe.getResult());
|
||||
}
|
||||
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
if (oldRecipe.getRow(i) != null) {
|
||||
items.extractItem(i, oldRecipe.getRow(i).stackSize, false);
|
||||
}
|
||||
}
|
||||
|
||||
progress = 0;
|
||||
markDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void refresh() {
|
||||
boolean wasWorking = working;
|
||||
|
||||
if (items.getStackInSlot(1) == null && items.getStackInSlot(2) == null && items.getStackInSlot(3) == null) {
|
||||
stop();
|
||||
} else {
|
||||
ISoldererRecipe newRecipe = SoldererRegistry.getRecipe(items);
|
||||
|
||||
if (newRecipe == null) {
|
||||
@@ -85,22 +55,39 @@ public class TileSolderer extends TileMachine {
|
||||
recipe = newRecipe;
|
||||
progress = 0;
|
||||
working = true;
|
||||
|
||||
markDirty();
|
||||
}
|
||||
} else if (working) {
|
||||
progress += 1 + RefinedStorageUtils.getUpgradeCount(upgrades, ItemUpgrade.TYPE_SPEED);
|
||||
|
||||
if (progress >= recipe.getDuration()) {
|
||||
if (items.getStackInSlot(3) != null) {
|
||||
items.getStackInSlot(3).stackSize += recipe.getResult().stackSize;
|
||||
} else {
|
||||
items.setStackInSlot(3, recipe.getResult());
|
||||
}
|
||||
|
||||
// We're checking if there is a world because this might be called from readFromNBT
|
||||
if (worldObj != null && wasWorking != working) {
|
||||
RefinedStorageUtils.updateBlock(worldObj, pos);
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
if (recipe.getRow(i) != null) {
|
||||
items.extractItem(i, recipe.getRow(i).stackSize, false);
|
||||
}
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
recipe = null;
|
||||
progress = 0;
|
||||
working = false;
|
||||
// Don't set working to false yet, wait till the next update because we may have
|
||||
// another stack waiting.
|
||||
|
||||
markDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (wasWorking != working) {
|
||||
RefinedStorageUtils.updateBlock(worldObj, pos);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisconnected(World world) {
|
||||
@@ -109,6 +96,14 @@ public class TileSolderer extends TileMachine {
|
||||
stop();
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
progress = 0;
|
||||
working = false;
|
||||
recipe = null;
|
||||
|
||||
markDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(NBTTagCompound nbt) {
|
||||
super.read(nbt);
|
||||
|
||||
Reference in New Issue
Block a user