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