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