Fixed autocrafting getting stuck with processing patterns #389
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
### 1.1.2
|
||||
- It is now possible to start a crafting task even if the crafting preview says you can't (raoulvdberge)
|
||||
- Fixed crash when changing screens in autocrafting (raoulvdberge)
|
||||
- Fixed autocrafting getting stuck with processing patterns (raoulvdberge)
|
||||
|
||||
### 1.1.1
|
||||
- Fixed crash on servers (raoulvdberge)
|
||||
|
@@ -52,9 +52,10 @@ public interface ICraftingTask {
|
||||
/**
|
||||
* Returns the status of this crafting task that is used for the tooltip in the crafting monitor.
|
||||
*
|
||||
* @param network the network
|
||||
* @return the status
|
||||
*/
|
||||
String getStatus();
|
||||
String getStatus(INetworkMaster network);
|
||||
|
||||
/**
|
||||
* @return the progress for display in the crafting monitor, or -1 to not display any progress
|
||||
|
@@ -54,7 +54,7 @@ public class CraftingTaskNormal extends CraftingTask {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStatus() {
|
||||
public String getStatus(INetworkMaster network) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
boolean missingItems = false;
|
||||
|
@@ -20,8 +20,6 @@ public class CraftingTaskProcessing extends CraftingTask {
|
||||
private boolean satisfiedInsertion[];
|
||||
private BlockPos tileInUse;
|
||||
|
||||
private boolean waitingOnTileInUse;
|
||||
|
||||
public CraftingTaskProcessing(ICraftingPattern pattern, int depth) {
|
||||
super(pattern, depth);
|
||||
|
||||
@@ -64,18 +62,10 @@ public class CraftingTaskProcessing extends CraftingTask {
|
||||
|
||||
ICraftingPatternContainer container = pattern.getContainer();
|
||||
|
||||
if (container.getFacingTile() == null) {
|
||||
tileInUse = null;
|
||||
|
||||
waitingOnTileInUse = false;
|
||||
}
|
||||
|
||||
if (!took.isEmpty() && container.getFacingTile() != null) {
|
||||
waitingOnTileInUse = isTileInUse(network);
|
||||
|
||||
if (!waitingOnTileInUse) {
|
||||
tileInUse = pattern.getContainer().getFacingTile().getPos();
|
||||
if (container.getFacingTile() != null && !isTileInUse(network)) {
|
||||
tileInUse = pattern.getContainer().getFacingTile().getPos();
|
||||
|
||||
if (!took.isEmpty()) {
|
||||
ItemStack toInsert = took.get(0);
|
||||
|
||||
if (ItemHandlerHelper.insertItem(container.getFacingInventory(), toInsert, true) == null) {
|
||||
@@ -84,6 +74,8 @@ public class CraftingTaskProcessing extends CraftingTask {
|
||||
took.remove(0);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
tileInUse = null;
|
||||
}
|
||||
|
||||
return isReady();
|
||||
@@ -110,9 +102,11 @@ public class CraftingTaskProcessing extends CraftingTask {
|
||||
}
|
||||
|
||||
private boolean isTileInUse(INetworkMaster network) {
|
||||
for (ICraftingTask task : network.getCraftingTasks()) {
|
||||
if (isTileInUse(task)) {
|
||||
return true;
|
||||
if (tileInUse == null) {
|
||||
for (ICraftingTask task : network.getCraftingTasks()) {
|
||||
if (isTileInUse(task)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,17 +114,19 @@ public class CraftingTaskProcessing extends CraftingTask {
|
||||
}
|
||||
|
||||
private boolean isTileInUse(ICraftingTask task) {
|
||||
if (task != this) {
|
||||
if (task.getChild() != null) {
|
||||
return isTileInUse(task.getChild());
|
||||
}
|
||||
if (task == this) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (task instanceof CraftingTaskProcessing) {
|
||||
CraftingTaskProcessing other = (CraftingTaskProcessing) task;
|
||||
if (task.getChild() != null) {
|
||||
return isTileInUse(task.getChild());
|
||||
}
|
||||
|
||||
if (other.tileInUse != null && other.tileInUse.equals(pattern.getContainer().getFacingTile().getPos()) && !other.pattern.equals(pattern)) {
|
||||
return true;
|
||||
}
|
||||
if (task instanceof CraftingTaskProcessing) {
|
||||
CraftingTaskProcessing other = (CraftingTaskProcessing) task;
|
||||
|
||||
if (other.tileInUse != null && other.tileInUse.equals(pattern.getContainer().getFacingTile().getPos()) && !other.pattern.equals(pattern)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,7 +171,7 @@ public class CraftingTaskProcessing extends CraftingTask {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStatus() {
|
||||
public String getStatus(INetworkMaster network) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
boolean missingItems = false;
|
||||
@@ -219,7 +215,7 @@ public class CraftingTaskProcessing extends CraftingTask {
|
||||
|
||||
if (pattern.getContainer().getFacingTile() == null) {
|
||||
builder.append("B=gui.refinedstorage:crafting_monitor.machine_none");
|
||||
} else if (waitingOnTileInUse) {
|
||||
} else if (isTileInUse(network)) {
|
||||
builder.append("B=gui.refinedstorage:crafting_monitor.machine_in_use");
|
||||
}
|
||||
}
|
||||
|
@@ -2,6 +2,7 @@ package refinedstorage.tile;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import refinedstorage.api.autocrafting.task.ICraftingTask;
|
||||
import refinedstorage.api.network.INetworkMaster;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -26,11 +27,11 @@ public class ClientCraftingTask {
|
||||
this.progress = progress;
|
||||
}
|
||||
|
||||
public ClientCraftingTask(String status, List<ItemStack> outputs, int progress, ICraftingTask child) {
|
||||
this.status = status;
|
||||
this.outputs = outputs;
|
||||
this.progress = progress;
|
||||
this.child = child != null ? new ClientCraftingTask(child.getStatus(), child.getPattern().getOutputs(), child.getProgress(), child.getChild()) : null;
|
||||
public ClientCraftingTask(INetworkMaster network, ICraftingTask task) {
|
||||
this.status = task.getStatus(network);
|
||||
this.outputs = task.getPattern().getOutputs();
|
||||
this.progress = task.getProgress();
|
||||
this.child = task.getChild() != null ? new ClientCraftingTask(network, task.getChild()) : null;
|
||||
}
|
||||
|
||||
public ItemStack getOutput() {
|
||||
|
@@ -15,12 +15,7 @@ public class TileCraftingMonitor extends TileNode {
|
||||
@Override
|
||||
public List<ClientCraftingTask> getValue(TileCraftingMonitor tile) {
|
||||
if (tile.connected) {
|
||||
return tile.network.getCraftingTasks().stream().map(t -> new ClientCraftingTask(
|
||||
t.getStatus(),
|
||||
t.getPattern().getOutputs(),
|
||||
t.getProgress(),
|
||||
t.getChild()
|
||||
)).collect(Collectors.toList());
|
||||
return tile.network.getCraftingTasks().stream().map(t -> new ClientCraftingTask(tile.network, t)).collect(Collectors.toList());
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
Reference in New Issue
Block a user