Fixed Interface with Crafting Upgrade being stuck if an earlier item configuration has missing items or fluids. Fixes #2114

This commit is contained in:
raoulvdberge
2018-12-01 16:55:46 +01:00
parent 55c38ad11d
commit cb58826f1e
6 changed files with 55 additions and 18 deletions

View File

@@ -1,5 +1,8 @@
# Refined Storage Changelog # Refined Storage Changelog
### 1.6.13
- Fixed Interface with Crafting Upgrade being stuck if an earlier item configuration has missing items or fluids (raoulvdberge)
### 1.6.12 ### 1.6.12
- Increased the speed of autocrafting (raoulvdberge) - Increased the speed of autocrafting (raoulvdberge)
- Fixed External Storage sending storage updates when it is disabled (raoulvdberge) - Fixed External Storage sending storage updates when it is disabled (raoulvdberge)

View File

@@ -2,7 +2,6 @@ package com.raoulvdberge.refinedstorage.api.autocrafting;
import com.raoulvdberge.refinedstorage.api.autocrafting.craftingmonitor.ICraftingMonitorListener; import com.raoulvdberge.refinedstorage.api.autocrafting.craftingmonitor.ICraftingMonitorListener;
import com.raoulvdberge.refinedstorage.api.autocrafting.task.ICraftingTask; import com.raoulvdberge.refinedstorage.api.autocrafting.task.ICraftingTask;
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNode;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
@@ -78,7 +77,7 @@ public interface ICraftingManager {
ICraftingPatternChainList createPatternChainList(); ICraftingPatternChainList createPatternChainList();
/** /**
* @deprecated Use {@link #request(INetworkNode, ItemStack, int)} * @deprecated Use {@link #request(Object, ItemStack, int)}
*/ */
@Nullable @Nullable
@Deprecated @Deprecated
@@ -87,7 +86,7 @@ public interface ICraftingManager {
} }
/** /**
* @deprecated Use {@link #request(INetworkNode, FluidStack, int)} * @deprecated Use {@link #request(Object, FluidStack, int)}
*/ */
@Nullable @Nullable
@Deprecated @Deprecated
@@ -104,7 +103,7 @@ public interface ICraftingManager {
* @return the crafting task created, or null if no task is created * @return the crafting task created, or null if no task is created
*/ */
@Nullable @Nullable
ICraftingTask request(INetworkNode source, ItemStack stack, int amount); ICraftingTask request(Object source, ItemStack stack, int amount);
/** /**
* Schedules a crafting task if the task isn't scheduled yet. * Schedules a crafting task if the task isn't scheduled yet.
@@ -115,7 +114,7 @@ public interface ICraftingManager {
* @return the crafting task created, or null if no task is created * @return the crafting task created, or null if no task is created
*/ */
@Nullable @Nullable
ICraftingTask request(INetworkNode source, FluidStack stack, int amount); ICraftingTask request(Object source, FluidStack stack, int amount);
/** /**
* Tracks an incoming stack. * Tracks an incoming stack.

View File

@@ -44,7 +44,7 @@ public class CraftingManager implements ICraftingManager {
private List<UUID> tasksToCancel = new ArrayList<>(); private List<UUID> tasksToCancel = new ArrayList<>();
private NBTTagList tasksToRead; private NBTTagList tasksToRead;
private Map<INetworkNode, Long> throttledRequesters = new HashMap<>(); private Map<Object, Long> throttledRequesters = new HashMap<>();
private Set<ICraftingMonitorListener> listeners = new HashSet<>(); private Set<ICraftingMonitorListener> listeners = new HashSet<>();
@@ -228,7 +228,7 @@ public class CraftingManager implements ICraftingManager {
@Override @Override
@Nullable @Nullable
public ICraftingTask request(INetworkNode source, ItemStack stack, int amount) { public ICraftingTask request(Object source, ItemStack stack, int amount) {
if (isThrottled(source)) { if (isThrottled(source)) {
return null; return null;
} }
@@ -264,7 +264,7 @@ public class CraftingManager implements ICraftingManager {
@Nullable @Nullable
@Override @Override
public ICraftingTask request(INetworkNode source, FluidStack stack, int amount) { public ICraftingTask request(Object source, FluidStack stack, int amount) {
if (isThrottled(source)) { if (isThrottled(source)) {
return null; return null;
} }
@@ -298,22 +298,22 @@ public class CraftingManager implements ICraftingManager {
return null; return null;
} }
private void throttle(@Nullable INetworkNode node) { private void throttle(@Nullable Object source) {
OneSixMigrationHelper.removalHook(); // Remove @Nullable node OneSixMigrationHelper.removalHook(); // Remove @Nullable source
if (node != null) { if (source != null) {
throttledRequesters.put(node, MinecraftServer.getCurrentTimeMillis()); throttledRequesters.put(source, MinecraftServer.getCurrentTimeMillis());
} }
} }
private boolean isThrottled(@Nullable INetworkNode node) { private boolean isThrottled(@Nullable Object source) {
OneSixMigrationHelper.removalHook(); // Remove @Nullable node OneSixMigrationHelper.removalHook(); // Remove @Nullable source
if (node == null) { if (source == null) {
return false; return false;
} }
Long throttledSince = throttledRequesters.get(node); Long throttledSince = throttledRequesters.get(source);
if (throttledSince == null) { if (throttledSince == null) {
return false; return false;
} }

View File

@@ -89,7 +89,7 @@ public class NetworkNodeExporter extends NetworkNode implements IComparable, ITy
if (took == null) { if (took == null) {
if (upgrades.hasUpgrade(ItemUpgrade.TYPE_CRAFTING)) { if (upgrades.hasUpgrade(ItemUpgrade.TYPE_CRAFTING)) {
network.getCraftingManager().request(this, slot, stackSize); network.getCraftingManager().request(new SlottedCraftingRequest(this, filterSlot), slot, stackSize);
} }
} else if (ItemHandlerHelper.insertItem(handler, took, true).isEmpty()) { } else if (ItemHandlerHelper.insertItem(handler, took, true).isEmpty()) {
took = network.extractItem(slot, Math.min(slot.getMaxStackSize(), stackSize), compare, Action.PERFORM); took = network.extractItem(slot, Math.min(slot.getMaxStackSize(), stackSize), compare, Action.PERFORM);

View File

@@ -119,7 +119,7 @@ public class NetworkNodeInterface extends NetworkNode implements IComparable {
delta -= result == null ? 0 : result.getCount(); delta -= result == null ? 0 : result.getCount();
if (delta > 0 && upgrades.hasUpgrade(ItemUpgrade.TYPE_CRAFTING)) { if (delta > 0 && upgrades.hasUpgrade(ItemUpgrade.TYPE_CRAFTING)) {
network.getCraftingManager().request(this, wanted, delta); network.getCraftingManager().request(new SlottedCraftingRequest(this, i), wanted, delta);
} }
} else if (delta < 0) { } else if (delta < 0) {
ItemStack remainder = network.insertItemTracked(got, Math.abs(delta)); ItemStack remainder = network.insertItemTracked(got, Math.abs(delta));

View File

@@ -0,0 +1,35 @@
package com.raoulvdberge.refinedstorage.apiimpl.network.node;
import com.raoulvdberge.refinedstorage.api.network.node.INetworkNode;
import java.util.Objects;
public class SlottedCraftingRequest {
private INetworkNode node;
private int slot;
public SlottedCraftingRequest(INetworkNode node, int slot) {
this.node = node;
this.slot = slot;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
SlottedCraftingRequest that = (SlottedCraftingRequest) o;
return slot == that.slot && Objects.equals(node, that.node);
}
@Override
public int hashCode() {
return Objects.hash(node, slot);
}
}