Jump to content

Recommended Posts

Posted

How can I connect IInteractionObject with my Gui?
My target is to open gui (with no container) through clicking on entity and I want to make it compatible both with client and server side.
I have my gui registred in this way in the main mod file 

		ModLoadingContext.get().registerExtensionPoint(ExtensionPoint.GUIFACTORY, ()->GuiOldMan::new);

At first I tried to make my GuiOldMan implements IInteractionObject but the whole gui is client side only so it didn't work for the server.
I am trying to open Gui using

NetworkHooks.openGui((EntityPlayerMP) player, new GuiOldMan());

I've been also trying to make separate object that implements IInteractionObject, but I don't know how to connect this object with gui.
Thanks in Advance!


 

Posted (edited)
  On 6/16/2019 at 9:30 AM, diesieben07 said:

If your GUI is client-only just use Minecraft#displayGuiScreen. IInteractionObject and friends are for GUIs that need server<>client interaction.

Expand  

yeah I have tried that using 

  Quote

if(world.isRemote)

Expand  

but it doesn't work when running on a server.
Also I've been trying to make it work on server using packets (server -> client -> open Gui) but it doesn't work.

Edited by Krevik
Posted (edited)
  On 6/16/2019 at 9:41 AM, diesieben07 said:

Show your attempt at using a packet. And elaborate on "doesn't work".

Expand  

When I try using Minecraft.getInstance.displayGui() inside if(world.isRemote()) I am getting crash when starting server

Attempted to load class net/minecraft/client/gui/GuiScreen for invalid dist DEDICATED_SERVER



My attempt for using packet:
ProcessInteract Method:

  Reveal hidden contents


Packet Handler class:

  Reveal hidden contents

 

PacketClientOpenGuiOldMan class:

  Reveal hidden contents


When trying to use this way, I am getting the same error when trying run the server - attempted to load class for invalid dist

Edited by Krevik
Posted
  On 6/16/2019 at 9:55 AM, diesieben07 said:

Have you looked at the methods the class provides? They have some documentation and are in general quite straightforward...

Expand  

Well only one method here contains any documentation. But you're right they seem easy, I should be able to do that now. Thanks a lot!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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