mirror of
https://github.com/GTNewHorizons/Binnie.git
synced 2026-11-19 03:49:07 +00:00
Fix #137 [1.11.2] Lumbermill keeps working when bark and sawdust slots full.
This commit is contained in:
1 parent
05308e82c8
commit
564f586c58
1 file changed
+23
-8
@@ -3,6 +3,7 @@ package binnie.extratrees.machines.lumbermill;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import binnie.core.machines.Machine;
|
||||
import binnie.core.machines.MachineUtil;
|
||||
import binnie.core.machines.power.ComponentProcessSetCost;
|
||||
import binnie.core.machines.power.ErrorState;
|
||||
import binnie.core.machines.power.IProcess;
|
||||
@@ -19,17 +20,30 @@ public class LumbermillLogic extends ComponentProcessSetCost implements IProcess
|
||||
|
||||
@Override
|
||||
public ErrorState canWork() {
|
||||
ItemStack logStack = this.getUtil().getStack(LumbermillMachine.SLOT_LOG);
|
||||
MachineUtil util = getUtil();
|
||||
ItemStack logStack = util.getStack(LumbermillMachine.SLOT_LOG);
|
||||
if (logStack.isEmpty()) {
|
||||
return new ErrorState.NoItem("No Wood", LumbermillMachine.SLOT_LOG);
|
||||
}
|
||||
final ItemStack plankResult = LumbermillRecipes.getPlankProduct(logStack);
|
||||
if (!this.getUtil().isSlotEmpty(LumbermillMachine.SLOT_PLANKS) && plankResult != null) {
|
||||
final ItemStack currentPlank = this.getUtil().getStack(LumbermillMachine.SLOT_PLANKS);
|
||||
if (!util.isSlotEmpty(LumbermillMachine.SLOT_PLANKS) && !plankResult.isEmpty()) {
|
||||
final ItemStack currentPlank = util.getStack(LumbermillMachine.SLOT_PLANKS);
|
||||
if (!plankResult.isItemEqual(currentPlank) || plankResult.getCount() + currentPlank.getCount() > currentPlank.getMaxStackSize()) {
|
||||
return new ErrorState.NoSpace("No room for new planks", new int[]{LumbermillMachine.SLOT_PLANKS});
|
||||
}
|
||||
}
|
||||
if(!util.isSlotEmpty(LumbermillMachine.SLOT_BARK)){
|
||||
ItemStack itemStack = util.getStack(LumbermillMachine.SLOT_BARK);
|
||||
if (itemStack.getCount() + 1 > itemStack.getMaxStackSize()) {
|
||||
return new ErrorState.NoSpace("No room for new bark", new int[]{LumbermillMachine.SLOT_BARK});
|
||||
}
|
||||
}
|
||||
if(!util.isSlotEmpty(LumbermillMachine.SLOT_SAWDUST)){
|
||||
ItemStack itemStack = util.getStack(LumbermillMachine.SLOT_SAWDUST);
|
||||
if (itemStack.getCount() + 1 > itemStack.getMaxStackSize()) {
|
||||
return new ErrorState.NoSpace("No room for new sawdust", new int[]{LumbermillMachine.SLOT_SAWDUST});
|
||||
}
|
||||
}
|
||||
return super.canWork();
|
||||
}
|
||||
|
||||
@@ -43,15 +57,16 @@ public class LumbermillLogic extends ComponentProcessSetCost implements IProcess
|
||||
|
||||
@Override
|
||||
protected void onFinishTask() {
|
||||
final ItemStack logStack = this.getUtil().getStack(LumbermillMachine.SLOT_LOG);
|
||||
MachineUtil util = getUtil();
|
||||
final ItemStack logStack = util.getStack(LumbermillMachine.SLOT_LOG);
|
||||
final ItemStack result = LumbermillRecipes.getPlankProduct(logStack);
|
||||
if (result == null) {
|
||||
return;
|
||||
}
|
||||
this.getUtil().addStack(LumbermillMachine.SLOT_PLANKS, result);
|
||||
this.getUtil().addStack(LumbermillMachine.SLOT_SAWDUST, ExtraTreeItems.Sawdust.get(1));
|
||||
this.getUtil().addStack(LumbermillMachine.SLOT_BARK, ExtraTreeItems.Bark.get(1));
|
||||
this.getUtil().decreaseStack(LumbermillMachine.SLOT_LOG, 1);
|
||||
util.addStack(LumbermillMachine.SLOT_PLANKS, result);
|
||||
util.addStack(LumbermillMachine.SLOT_SAWDUST, ExtraTreeItems.Sawdust.get(1));
|
||||
util.addStack(LumbermillMachine.SLOT_BARK, ExtraTreeItems.Bark.get(1));
|
||||
util.decreaseStack(LumbermillMachine.SLOT_LOG, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user