Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.19] Creating new GUI Screen


Zanckor
 Share

Recommended Posts

Yo! Here again, I'm trying to create a new custom GUI Screen, smthing like, press V and it displays a GUI with buttons, etc.

So, how can I create it? extending screen? And how can I register it? Btw, there's any doc or example?

Link to comment
Share on other sites

24 minutes ago, Zanckor said:

So, how can I create it?

depends on what the Screen should do? Do you only want to have a Button?

24 minutes ago, Zanckor said:

extending screen?

a Screen extension is in all cases required

25 minutes ago, Zanckor said:

Btw, there's any doc or example?

unfortunately there is no doc but you can take a look at all vanilla Screens as an example

Link to comment
Share on other sites

1 minute ago, Luis_ST said:

depends on what the Screen should do? Do you only want to have a Button?

I want a Button that increase a capability per one, like a stat "Stamina" that i want to increase one per one.

Something like a MMORPG menu to increase my stats

Link to comment
Share on other sites

create a new class and extends Screen,
override #init and add there all Buttons you want (use #addRenderableWidget)

inside the OnPress action of the Button you need to send a custom Network Packet (see: https://forge.gemwire.uk/wiki/SimpleChannel) to the server
which increase your Capability value, if your Capability is also required on the client you need to sync it back after the value changes

  • Thanks 1
Link to comment
Share on other sites

2 minutes ago, diesieben07 said:

Do not use @OnlyIn.

ItemPickupEvent is a server side event, you cannot directly open a screen from there.

Oh okay, i was thinking that too xD, and about the rest of the code? There's something wrong?

Link to comment
Share on other sites

Posted (edited)
15 minutes ago, Zanckor said:

about the rest of the code? There's something wrong?

looks okay, your Button is just 1x1 large but everything else looks okay

Edit: you should not super null in the constructor

Edited by Luis_ST
  • Thanks 1
Link to comment
Share on other sites

Posted (edited)

You need a render method in your screen and then use renderBackground()

Don't forget to call super.render() after that to draw the widgets.

There is also renderDirtBackground() if you want that.

Edited by warjort
  • Thanks 1
Link to comment
Share on other sites

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

 Share



×
×
  • Create New...

Important Information

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