Jump to content

[1.8][SOLVED] Can/How to get currently opened container server-side?


Recommended Posts

Posted

I need to send packet from GuiContainer and I don't want unnecessary data to be send - x/y/z of tileEntity the container was opened from.

 

How would I optain server-sided container from player?

1.7.10 is no longer supported by forge, you are on your own.

Posted

Nope, I alredy checked. That is always PlayerInv.

It must not, according to FMLNetworkHandler.openGui:

            EntityPlayerMP entityPlayerMP = (EntityPlayerMP) entityPlayer;
            Container remoteGuiContainer = NetworkRegistry.INSTANCE.getRemoteGuiContainer(mc, entityPlayerMP, modGuiId, world, x, y, z);
            if (remoteGuiContainer != null)
            {
                entityPlayerMP.getNextWindowId();
                entityPlayerMP.closeContainer();
                int windowId = entityPlayerMP.currentWindowId;
                FMLMessage.OpenGui openGui = new FMLMessage.OpenGui(windowId, mc.getModId(), modGuiId, x, y, z);
                EmbeddedChannel embeddedChannel = channelPair.get(Side.SERVER);
                embeddedChannel.attr(FMLOutboundHandler.FML_MESSAGETARGET).set(OutboundTarget.PLAYER);
                embeddedChannel.attr(FMLOutboundHandler.FML_MESSAGETARGETARGS).set(entityPlayerMP);
                embeddedChannel.writeOutbound(openGui);
                entityPlayerMP.openContainer = remoteGuiContainer;
                entityPlayerMP.openContainer.windowId = windowId;
                entityPlayerMP.openContainer.addCraftingToCrafters(entityPlayerMP);
            }

 

EDIT: More informative reading gives following: if no container is opened, then openContainer=playerInventory, else it is opened container (inventory if inventory is opened)...

EDIT 2: To check that, read all occurences of openContainer in EntityPlayer, and you will understand what is happenning...

Posted

That is indeed correct.

 

I wonder why I had that glitch ;o I was printing openContainer and it was always PlayerInv, strange.

 

CLOSED

1.7.10 is no longer supported by forge, you are on your own.

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.