mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-18 19:39:06 +00:00
Fix inventory desync when closing GuiRecipe (#320)
This commit is contained in:
1 parent
2130a47f6f
commit
336c7dc621
3 files changed
+18
No files matched your search
@@ -141,6 +141,13 @@ public class NEICPH implements IClientPacketHandler {
|
||||
packet.sendToServer();
|
||||
}
|
||||
|
||||
public static void sendRequestContainer() {
|
||||
PacketCustom packet = new PacketCustom(channel, 16);
|
||||
packet.writeInt(
|
||||
Minecraft.getMinecraft().thePlayer.openContainer.getInventory().size());
|
||||
packet.sendToServer();
|
||||
}
|
||||
|
||||
public static void sendSetSlot(int slot, ItemStack stack, boolean container) {
|
||||
PacketCustom packet = new PacketCustom(channel, 5);
|
||||
packet.writeBoolean(container);
|
||||
|
||||
@@ -64,6 +64,9 @@ public class NEISPH implements IServerPacketHandler {
|
||||
case 15:
|
||||
handleMobSpawnerID(sender.worldObj, packet.readCoord(), packet.readString());
|
||||
break;
|
||||
case 16:
|
||||
handleRequestContainer(sender, packet.readInt());
|
||||
break;
|
||||
case 21:
|
||||
openEnchantmentGui(sender);
|
||||
break;
|
||||
@@ -99,6 +102,11 @@ public class NEISPH implements IServerPacketHandler {
|
||||
}
|
||||
}
|
||||
|
||||
private void handleRequestContainer(EntityPlayerMP sender, int containerSize) {
|
||||
if (sender.openContainer.getInventory().size() != containerSize) return;
|
||||
sender.sendContainerToPlayer(sender.openContainer);
|
||||
}
|
||||
|
||||
private void handlePropertyChange(EntityPlayerMP sender, PacketCustom packet) {
|
||||
String name = packet.readString();
|
||||
if (NEIServerConfig.canPlayerPerformAction(sender.getCommandSenderName(), name))
|
||||
|
||||
@@ -3,6 +3,7 @@ package codechicken.nei.recipe;
|
||||
import codechicken.lib.gui.GuiDraw;
|
||||
import codechicken.nei.GuiNEIButton;
|
||||
import codechicken.nei.LayoutManager;
|
||||
import codechicken.nei.NEICPH;
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.NEIClientUtils;
|
||||
import codechicken.nei.PositionedStack;
|
||||
@@ -336,6 +337,7 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer
|
||||
if (i == Keyboard.KEY_ESCAPE) // esc
|
||||
{
|
||||
mc.displayGuiScreen(firstGuiGeneral);
|
||||
NEICPH.sendRequestContainer();
|
||||
return;
|
||||
}
|
||||
if (GuiContainerManager.getManager(this).lastKeyTyped(i, c)) return;
|
||||
@@ -346,6 +348,7 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer
|
||||
|
||||
if (i == mc.gameSettings.keyBindInventory.getKeyCode()) {
|
||||
mc.displayGuiScreen(firstGuiGeneral);
|
||||
NEICPH.sendRequestContainer();
|
||||
} else if (NEIClientConfig.isKeyHashDown("gui.back")) {
|
||||
mc.displayGuiScreen(prevGui);
|
||||
} else if (NEIClientConfig.isKeyHashDown("gui.prev_machine")) {
|
||||
|
||||
Reference in new issue
Block a user