Skip to content

Instantly share code, notes, and snippets.

@MultiMote
Created October 15, 2014 09:33
Show Gist options
  • Save MultiMote/078dbf0cd90c5ab8a6f0 to your computer and use it in GitHub Desktop.
Save MultiMote/078dbf0cd90c5ab8a6f0 to your computer and use it in GitHub Desktop.
//////////////////////////////
//// MOD FILE
//////////////////////////////
public static SimpleNetworkWrapper packets;
@EventHandler
public void postInit(FMLPostInitializationEvent event) {
packets = NetworkRegistry.INSTANCE.newSimpleChannel("SomeName");
packets.registerMessage(GuiRequestPacket.class, GuiRequestPacket.class, 0, Side.SERVER); //Packed id, 0-31
}
//////////////////////////////
//// GUI FILE
//////////////////////////////
@Override
protected void actionPerformed(GuiButton button) {
// you need to store entity instance when opening gui, trader in my case.
if(button == yourbutton) Core.packets.sendToServer(new GuiRequestPacket(3, this.trader.getEntityId())); // 3 is your gui id (from your code)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment