Jump to content

Recommended Posts

Posted

Hi,

I am trying to make a GUI for Entities, so the GUI shall display when I interact with the NPC.

My question is, what would be the simplest way to do this?

 

Should I let my use the Interface IMerchant for my villager or rather the IInteractionObject?

Or does forge come with an even easier method?

 

Thanks in advance :)

Posted

I'm not sure I understand what you want. Do you want to open a GUI when you right click a villager? If so, EntityInteractEvent could work. Just check whether the player's target is your villager. Then open your GUI.

Posted

Wups, I just see my explanation wasn't the best :D

 

I have a custom Entity, an NPC. When rightclicked, I want it to display a GUI and add a way to communicate with the NPC, get Quests etc. . The only problem is that, other than with blocks, most GUIs seem to be hardcoded when it comes to players:

 

player.displayGUIHorse()
player.displayGUIBook()
player.disiplayGUIChest()

 

Those functions above are very specific and don't give me what I would like to do.

 

The two functions I consider tapping into are either:

 

player.displayGUI()
player.displayVillageTraderGUI()

 

The first one requires IInteractionObject as parameter,

the second one the IMerchant interface implemented in my Entity.

I wonder, which was is easier to do? Or is there one of the two ways not even possible?

 

Thanks again for any response (:

Posted

player.openGui(...)

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

So I am trying this, but without any success...

 

I implemented IInteractionObject in the NPCs class, created the GUI, the Container, a GuiHandler, registered it in the modfile, and so on. But unfortunatly my GUI still doesn't open. Could somebody look over my code?

 

Possible problems could be the GuiHandler, or the @Override functions that came with the implementation of IInteractionObject into the NPCs class, I might have done something wrong...

 

 

This is my NPCs class:

 

  Reveal hidden contents

 

 

This is my GuiContainer

 

  Reveal hidden contents

 

 

This is my Gui

 

  Reveal hidden contents

 

 

This is my GuiHandler

 

  Reveal hidden contents

 

 

Thanks for any help again (:

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.