So, I’m doing some updating on an old plugin and I’ve run across an issue. Back in the 5.0 API, all I needed to get the Hotbar and Grid inventory was:
Hotbar hotbar = inv.query(Hotbar.class);
GridInventory gridInv = inv.query(GridInventory.class);
I tried the following code below and got no errors when compiling:
Hotbar hotbar = inv.query(QueryOperationTypes.INVENTORY_TYPE.of(Hotbar.class));
GridInventory gridInv = inv.query(QueryOperationTypes.INVENTORY_TYPE.of(GridInventory.class));
when I executed the command that ran this code, though, I got the following error:
[14:04:52] [Server thread/ERROR] [Sponge]: Error occurred while executing command 'dz join Stygia PAB' for source EntityPlayerMP['SalvadorZXA'/659, l='world', x=-396.36, y=90.00, z=818.19]: org.spongepowered.common.item.inventory.query.result.MinecraftResultAdapterProvider$MinecraftQueryResultAdapter cannot be cast to org.spongepowered.api.item.inventory.type.GridInventory
java.lang.ClassCastException: org.spongepowered.common.item.inventory.query.result.MinecraftResultAdapterProvider$MinecraftQueryResultAdapter cannot be cast to org.spongepowered.api.item.inventory.type.GridInventory
at com.salvadorzxa.DreadZone2.Utils.TempDataStorage.saveInv(TempDataStorage.java:44) ~[TempDataStorage.class:?]
at com.salvadorzxa.DreadZone2.Executors.JoinArena.join(JoinArena.java:271) ~[JoinArena.class:?]
at com.salvadorzxa.DreadZone2.Executors.JoinArena.execute(JoinArena.java:174) ~[JoinArena.class:?]
at org.spongepowered.api.command.args.ChildCommandElementExecutor.execute(ChildCommandElementExecutor.java:255) ~[ChildCommandElementExecutor.class:1.12.2-2705-7.1.0-BETA-3349]
at org.spongepowered.api.command.spec.CommandSpec.process(CommandSpec.java:388) ~[CommandSpec.class:1.12.2-2705-7.1.0-BETA-3349]
at org.spongepowered.api.command.dispatcher.SimpleDispatcher.process(SimpleDispatcher.java:341) ~[SimpleDispatcher.class:1.12.2-2705-7.1.0-BETA-3349]
at org.spongepowered.common.command.SpongeCommandManager.process(SpongeCommandManager.java:329) [SpongeCommandManager.class:1.12.2-2705-7.1.0-BETA-3349]
at net.minecraft.command.ServerCommandManager.func_71556_a(SourceFile:1083) [dh.class:?]
at net.minecraft.network.NetHandlerPlayServer.func_147361_d(NetHandlerPlayServer.java:958) [pa.class:?]
at net.minecraft.network.NetHandlerPlayServer.func_147354_a(NetHandlerPlayServer.java:937) [pa.class:?]
at net.minecraft.network.play.client.CPacketChatMessage.func_148833_a(SourceFile:37) [la.class:?]
at net.minecraft.network.play.client.CPacketChatMessage.func_148833_a(SourceFile:9) [la.class:?]
at org.spongepowered.common.network.PacketUtil.onProcessPacket(PacketUtil.java:92) [PacketUtil.class:1.12.2-2705-7.1.0-BETA-3349]
at net.minecraft.network.PacketThreadUtil$1.redirect$onProcessPacket$zld000(SourceFile:539) [hv$1.class:?]
at net.minecraft.network.PacketThreadUtil$1.run(SourceFile:13) [hv$1.class:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_181]
at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_181]
at net.minecraft.util.Util.func_181617_a(SourceFile:46) [h.class:?]
at org.spongepowered.common.SpongeImplHooks.onUtilRunTask(SpongeImplHooks.java:293) [SpongeImplHooks.class:1.12.2-2705-7.1.0-BETA-3349]
at net.minecraft.server.MinecraftServer.redirect$onRun$zji000(MinecraftServer.java:3963) [MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:723) [MinecraftServer.class:?]
at net.minecraft.server.dedicated.DedicatedServer.func_71190_q(DedicatedServer.java:396) [nz.class:?]
at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:668) [MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:526) [MinecraftServer.class:?]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_181]
It seems like it ran okay for the Hotbar, but not for the GridInventory. Did I mess up, or is this an actual bug? Thanks.
SpongeForge: spongeforge-1.12.2-2705-7.1.0-BETA-3349