Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

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

Featured Replies

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.

  • Author

Nope, I alredy checked. That is always PlayerInv.

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

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...

  • Author

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.

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.