Fix not being able to start crafting in a few cases
This commit is contained in:
@@ -44,10 +44,10 @@ public interface IItemGridHandler {
|
||||
/**
|
||||
* Called when a player requests the crafting preview window to be opened.
|
||||
*
|
||||
* @param stack the {@link ItemStack} to request a craft for
|
||||
* @param hash the item stack hash
|
||||
* @param quantity the amount of that item that we need a preview for
|
||||
*/
|
||||
void onCraftingPreviewRequested(EntityPlayerMP player, ItemStack stack, int quantity);
|
||||
void onCraftingPreviewRequested(EntityPlayerMP player, int hash, int quantity);
|
||||
|
||||
/**
|
||||
* Called when a player requested crafting for an item.
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.raoulvdberge.refinedstorage.apiimpl.network.grid;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.RS;
|
||||
import com.raoulvdberge.refinedstorage.RSUtils;
|
||||
import com.raoulvdberge.refinedstorage.api.autocrafting.ICraftingPattern;
|
||||
import com.raoulvdberge.refinedstorage.api.autocrafting.task.ICraftingTask;
|
||||
import com.raoulvdberge.refinedstorage.api.network.INetworkMaster;
|
||||
import com.raoulvdberge.refinedstorage.api.network.grid.IItemGridHandler;
|
||||
@@ -142,7 +141,9 @@ public class ItemGridHandler implements IItemGridHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCraftingPreviewRequested(EntityPlayerMP player, ItemStack stack, int quantity) {
|
||||
public void onCraftingPreviewRequested(EntityPlayerMP player, int hash, int quantity) {
|
||||
ItemStack stack = network.getItemStorageCache().getList().get(hash);
|
||||
|
||||
if (stack != null) {
|
||||
Thread calculationThread = new Thread(() -> {
|
||||
ICraftingTask task = new CraftingTask(network, stack, network.getPattern(stack), quantity);
|
||||
|
||||
@@ -176,7 +176,7 @@ public class GuiCraftingStart extends GuiBase {
|
||||
Integer quantity = Ints.tryParse(amountField.getText());
|
||||
|
||||
if (quantity != null && quantity > 0) {
|
||||
RS.INSTANCE.network.sendToServer(new MessageGridCraftingPreview(stack.getStack(), quantity));
|
||||
RS.INSTANCE.network.sendToServer(new MessageGridCraftingPreview(stack.getHash(), quantity));
|
||||
|
||||
startButton.enabled = false;
|
||||
}
|
||||
|
||||
@@ -4,31 +4,29 @@ import com.raoulvdberge.refinedstorage.container.ContainerGrid;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.common.network.ByteBufUtils;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
|
||||
public class MessageGridCraftingPreview extends MessageHandlerPlayerToServer<MessageGridCraftingPreview> implements IMessage {
|
||||
private ItemStack stack;
|
||||
private int hash;
|
||||
private int quantity;
|
||||
|
||||
public MessageGridCraftingPreview() {
|
||||
}
|
||||
|
||||
public MessageGridCraftingPreview(ItemStack stack, int quantity) {
|
||||
this.stack = stack;
|
||||
public MessageGridCraftingPreview(int hash, int quantity) {
|
||||
this.hash = hash;
|
||||
this.quantity = quantity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
stack = ByteBufUtils.readItemStack(buf);
|
||||
hash = buf.readInt();
|
||||
quantity = buf.readInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
ByteBufUtils.writeItemStack(buf, stack);
|
||||
buf.writeInt(hash);
|
||||
buf.writeInt(quantity);
|
||||
}
|
||||
|
||||
@@ -37,7 +35,7 @@ public class MessageGridCraftingPreview extends MessageHandlerPlayerToServer<Mes
|
||||
Container container = player.openContainer;
|
||||
|
||||
if (container instanceof ContainerGrid) {
|
||||
((ContainerGrid) container).getGrid().getItemHandler().onCraftingPreviewRequested(player, message.stack, message.quantity);
|
||||
((ContainerGrid) container).getGrid().getItemHandler().onCraftingPreviewRequested(player, message.hash, message.quantity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -455,8 +455,6 @@ public class TileController extends TileBase implements INetworkMaster, IRedston
|
||||
patterns.addAll(((ICraftingPatternContainer) node).getPatterns());
|
||||
}
|
||||
}
|
||||
|
||||
itemStorage.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -25,7 +25,6 @@ public abstract class TileNode extends TileBase implements INetworkNode, IRedsto
|
||||
|
||||
private RedstoneMode redstoneMode = RedstoneMode.IGNORE;
|
||||
private boolean active;
|
||||
private boolean rebuildNeighbors;
|
||||
protected boolean rebuildOnUpdateChange;
|
||||
|
||||
protected INetworkMaster network;
|
||||
@@ -49,7 +48,9 @@ public abstract class TileNode extends TileBase implements INetworkNode, IRedsto
|
||||
public void update() {
|
||||
if (!getWorld().isRemote) {
|
||||
boolean wasActive = active;
|
||||
|
||||
active = hasNetwork() && canUpdate();
|
||||
|
||||
if (active != wasActive) {
|
||||
if (hasConnectivityState()) {
|
||||
updateBlock();
|
||||
|
||||
Reference in New Issue
Block a user