Fixed not being able to craft Immersive Engineering Revolver, fixes #1465
This commit is contained in:
@@ -53,6 +53,7 @@ public interface IItemGridHandler {
|
||||
/**
|
||||
* Called when a player requests the crafting preview window to be opened.
|
||||
*
|
||||
* @param player the player
|
||||
* @param hash the item stack hash
|
||||
* @param quantity the amount of that item that we need a preview for
|
||||
* @param noPreview true if the crafting preview window shouldn't be shown, false otherwise
|
||||
@@ -63,10 +64,10 @@ public interface IItemGridHandler {
|
||||
* Called when a player requested crafting for an item.
|
||||
*
|
||||
* @param player the player that is requesting the crafting
|
||||
* @param stack the {@link ItemStack} to request a craft for
|
||||
* @param hash the hash of the item to request a craft for
|
||||
* @param quantity the amount of the item that has to be crafted
|
||||
*/
|
||||
void onCraftingRequested(EntityPlayerMP player, ItemStack stack, int quantity);
|
||||
void onCraftingRequested(EntityPlayerMP player, int hash, int quantity);
|
||||
|
||||
/**
|
||||
* Called when a player wants to cancel a crafting task.
|
||||
|
||||
@@ -183,20 +183,36 @@ public class ItemGridHandler implements IItemGridHandler {
|
||||
|
||||
RS.INSTANCE.network.sendTo(new MessageGridCraftingStartResponse(), player);
|
||||
} else {
|
||||
RS.INSTANCE.network.sendTo(new MessageGridCraftingPreviewResponse(task.getPreviewStacks(), stack, quantity), player);
|
||||
RS.INSTANCE.network.sendTo(new MessageGridCraftingPreviewResponse(task.getPreviewStacks(), hash, quantity), player);
|
||||
}
|
||||
}, "RS crafting calculation");
|
||||
}, "RS crafting preview calculation");
|
||||
|
||||
calculationThread.start();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCraftingRequested(EntityPlayerMP player, ItemStack stack, int quantity) {
|
||||
public void onCraftingRequested(EntityPlayerMP player, int hash, int quantity) {
|
||||
if (quantity <= 0 || !network.getSecurityManager().hasPermission(Permission.AUTOCRAFTING, player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack stack = null;
|
||||
|
||||
for (ICraftingPattern pattern : network.getCraftingManager().getPatterns()) {
|
||||
for (ItemStack output : pattern.getOutputs()) {
|
||||
if (output != null && API.instance().getItemStackHashCode(output) == hash) {
|
||||
stack = output;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (stack != null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (stack != null) {
|
||||
ICraftingTask task = new CraftingTask(network, stack, network.getCraftingManager().getPatternChain(stack), quantity, false);
|
||||
|
||||
|
||||
@@ -149,7 +149,7 @@ public class ItemGridHandlerPortable implements IItemGridHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCraftingRequested(EntityPlayerMP player, ItemStack stack, int quantity) {
|
||||
public void onCraftingRequested(EntityPlayerMP player, int hash, int quantity) {
|
||||
// NO OP
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ public class GuiCraftingPreview extends GuiBase {
|
||||
private List<ICraftingPreviewElement> stacks;
|
||||
private GuiScreen parent;
|
||||
|
||||
private ItemStack stack;
|
||||
private int hash;
|
||||
private int quantity;
|
||||
|
||||
private GuiButton startButton;
|
||||
@@ -52,7 +52,7 @@ public class GuiCraftingPreview extends GuiBase {
|
||||
|
||||
private IElementDrawers drawers = new CraftingPreviewElementDrawers();
|
||||
|
||||
public GuiCraftingPreview(GuiScreen parent, List<ICraftingPreviewElement> stacks, ItemStack stack, int quantity) {
|
||||
public GuiCraftingPreview(GuiScreen parent, List<ICraftingPreviewElement> stacks, int hash, int quantity) {
|
||||
super(new Container() {
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player) {
|
||||
@@ -63,7 +63,7 @@ public class GuiCraftingPreview extends GuiBase {
|
||||
this.stacks = new ArrayList<>(stacks);
|
||||
this.parent = parent;
|
||||
|
||||
this.stack = stack;
|
||||
this.hash = hash;
|
||||
this.quantity = quantity;
|
||||
|
||||
this.scrollbar = new Scrollbar(149, 20, 12, 119);
|
||||
@@ -184,7 +184,7 @@ public class GuiCraftingPreview extends GuiBase {
|
||||
}
|
||||
|
||||
private void startRequest() {
|
||||
RS.INSTANCE.network.sendToServer(new MessageGridCraftingStart(stack, quantity));
|
||||
RS.INSTANCE.network.sendToServer(new MessageGridCraftingStart(hash, quantity));
|
||||
|
||||
close();
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import com.raoulvdberge.refinedstorage.api.autocrafting.preview.ICraftingPreview
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.API;
|
||||
import com.raoulvdberge.refinedstorage.proxy.ProxyClient;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.common.network.ByteBufUtils;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
|
||||
@@ -15,21 +14,21 @@ import java.util.List;
|
||||
|
||||
public class MessageGridCraftingPreviewResponse implements IMessage, IMessageHandler<MessageGridCraftingPreviewResponse, IMessage> {
|
||||
public List<ICraftingPreviewElement> stacks;
|
||||
public ItemStack stack;
|
||||
public int hash;
|
||||
public int quantity;
|
||||
|
||||
public MessageGridCraftingPreviewResponse() {
|
||||
}
|
||||
|
||||
public MessageGridCraftingPreviewResponse(List<ICraftingPreviewElement> stacks, ItemStack stack, int quantity) {
|
||||
public MessageGridCraftingPreviewResponse(List<ICraftingPreviewElement> stacks, int hash, int quantity) {
|
||||
this.stacks = stacks;
|
||||
this.stack = stack;
|
||||
this.hash = hash;
|
||||
this.quantity = quantity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
this.stack = ByteBufUtils.readItemStack(buf);
|
||||
this.hash = buf.readInt();
|
||||
this.quantity = buf.readInt();
|
||||
|
||||
this.stacks = new LinkedList<>();
|
||||
@@ -43,8 +42,8 @@ public class MessageGridCraftingPreviewResponse implements IMessage, IMessageHan
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
ByteBufUtils.writeItemStack(buf, this.stack);
|
||||
buf.writeInt(this.quantity);
|
||||
buf.writeInt(hash);
|
||||
buf.writeInt(quantity);
|
||||
|
||||
buf.writeInt(stacks.size());
|
||||
|
||||
|
||||
@@ -5,31 +5,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 MessageGridCraftingStart extends MessageHandlerPlayerToServer<MessageGridCraftingStart> implements IMessage {
|
||||
private ItemStack stack;
|
||||
private int hash;
|
||||
private int quantity;
|
||||
|
||||
public MessageGridCraftingStart() {
|
||||
}
|
||||
|
||||
public MessageGridCraftingStart(ItemStack stack, int quantity) {
|
||||
this.stack = stack;
|
||||
public MessageGridCraftingStart(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);
|
||||
}
|
||||
|
||||
@@ -41,7 +39,7 @@ public class MessageGridCraftingStart extends MessageHandlerPlayerToServer<Messa
|
||||
IGrid grid = ((ContainerGrid) container).getGrid();
|
||||
|
||||
if (grid.getItemHandler() != null) {
|
||||
grid.getItemHandler().onCraftingRequested(player, message.stack, message.quantity);
|
||||
grid.getItemHandler().onCraftingRequested(player, message.hash, message.quantity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -293,7 +293,7 @@ public class ProxyClient extends ProxyCommon {
|
||||
screen = ((GuiCraftingStart) screen).getParent();
|
||||
}
|
||||
|
||||
FMLCommonHandler.instance().showGuiScreen(new GuiCraftingPreview(screen, message.stacks, message.stack, message.quantity));
|
||||
FMLCommonHandler.instance().showGuiScreen(new GuiCraftingPreview(screen, message.stacks, message.hash, message.quantity));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user