Conflict with CarryOn
Tschipp opened this issue ยท 2 comments
Hi!
It has gotten to my attention (Tschipp/CarryOn#76) that our mods are incompatible.
Carry On allows the player to pick up TileEntities and Entities with their bare hands. To balance this, the player is not allowed to switch slots, drop the item, break blocks or open the inventory while they are carrying.
This piece of code makes sure that any Inventory-related guis that the player opens get closed if they are carrying:
@SubscribeEvent
public void onGuiOpen(GuiOpenEvent event)
{
if (event.getGui() != null)
{
boolean inventory = event.getGui() instanceof GuiContainer;
EntityPlayer player = Minecraft.getMinecraft().player;
if (player != null)
{
ItemStack stack = player.getHeldItem(EnumHand.MAIN_HAND);
if (inventory && !stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile && ItemTile.hasTileData(stack))
{
event.setCanceled(true);
Minecraft.getMinecraft().currentScreen = null;
}
}
}
}
However, when PlayerStorage is installed the Inventory can be opened, but only after pressing the inventory button twice.
I've gone through the debugger and noticed, that your gui does extend GuiContainer, so my first suspicion was false.
When pressing the Inventory button once, my gui-opening-prevention succeeds, but for some reason, some weird desync thing happens. The player's main hand item gets set to air. Therefore, when pressing the inventory button again, my check fails because the client thinks that the hand is empty and the inventory gets opened.
I'm really not sure how/why this is happening, and if the error is on my or your end, but I hope we can resolve it!
Edit: This was reported for minecraft 1.12.2 with PlayerStorage 1.1.1
java.util.concurrent.ExecutionException: java.lang.IndexOutOfBoundsException: Index: 46, Size: 46
at java.util.concurrent.FutureTask.report(FutureTask.java:122) ~[?:1.8.0_151]
at java.util.concurrent.FutureTask.get(FutureTask.java:192) ~[?:1.8.0_151]
at net.minecraft.util.Util.runTask(Util.java:54) [Util.class:?]
at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1176) [Minecraft.class:?]
at net.minecraft.client.Minecraft.run(Minecraft.java:441) [Minecraft.class:?]
at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_151]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_151]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_151]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_151]
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_151]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_151]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_151]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_151]
at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
at GradleStart.main(GradleStart.java:26) [start/:?]
Caused by: java.lang.IndexOutOfBoundsException: Index: 46, Size: 46
at java.util.ArrayList.rangeCheck(ArrayList.java:657) ~[?:1.8.0_151]
at java.util.ArrayList.get(ArrayList.java:433) ~[?:1.8.0_151]
at net.minecraft.inventory.Container.getSlot(Container.java:141) ~[Container.class:?]
at net.minecraft.inventory.Container.setAll(Container.java:565) ~[Container.class:?]
at net.minecraft.client.network.NetHandlerPlayClient.handleWindowItems(NetHandlerPlayClient.java:1314) ~[NetHandlerPlayClient.class:?]
at net.minecraft.network.play.server.SPacketWindowItems.processPacket(SPacketWindowItems.java:68) ~[SPacketWindowItems.class:?]
at net.minecraft.network.play.server.SPacketWindowItems.processPacket(SPacketWindowItems.java:13) ~[SPacketWindowItems.class:?]
at net.minecraft.network.PacketThreadUtil$1.run(PacketThreadUtil.java:21) ~[PacketThreadUtil$1.class:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[?:1.8.0_151]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[?:1.8.0_151]
at net.minecraft.util.Util.runTask(Util.java:53) ~[Util.class:?]
... 15 more
this crash ocurred when I try press the inventory key for the first time. I guess that's why the hotbar is empty