Jump to content

[1.16.X] Help with custom gui


852Duarte

Recommended Posts

Small clarification, this is my very first mod on minecraft.

 

I basically cloned the minecraft crafting table to make more variables of it, it find out that the vanilla gui won't open if the block is not the original vanilla one.

Is there a tutorial o someone who can explain me to put a custom gui to my block and make it work like the vanilla one?

Link to comment
Share on other sites

I see you already made a post regarding the crafting table GUI: https://forums.minecraftforge.net/topic/92683-1163-my-item-gui-closes-instantaneously/

Didn't the answer you received help you? Does your GUI still open and closes right after, or doesn't show up at all? Be more specific please, and show what you tried

 

Check out the port of the BetterEnd fabric mod (WIP): https://www.curseforge.com/minecraft/mc-mods/betterend-forge-port

Link to comment
Share on other sites

2 minutes ago, Beethoven92 said:

I see you already made a post regarding the crafting table GUI: https://forums.minecraftforge.net/topic/92683-1163-my-item-gui-closes-instantaneously/

Didn't the answer you received help you? Does your GUI still open and closes right after, or doesn't show up at all? Be more specific please, and show what you tried

 

I understood what the problem was and try to solve it by following some tutorials in internet, everything that i found was related to chest and furnaces, and some commands that works in 1.15 but in 1.16 needs some new parameters, so i'm stuck again with the same 

 

This is my code, simple has the idea of the mod 1.thumb.png.c99035a8b643ff9e6aa7bca2dbb09608.png

 

2.png.aa04c5dc3864e22d02cd86e39e469c60.png

Link to comment
Share on other sites

Mmmm it seems you did not folllow the advice of Draco18s, which i'll quote here:

Quote

You're trying to use the vanilla crafting GUI.

The vanilla crafting gui checks to see if the block being accessed is The One And Only Vanilla Crafting Table.

Your block is not The One And Only Vanilla Crafting Table.

Therefor the use of that gui is invalid and thus closed.

Your block extends the vanilla CraftingTableBlock class, but its not the vanilla crafting table itself (Blocks.CRAFTING_TABLE)...the vanilla crafting table container checks for the player proximity only with the Block.CRAFTING_TABLE, so of course your block doesn't satisfy the condition for the container to open. I think you would need to create a custom container which extends WorkbenchContainer and override the canInteractWith method to check for proximity with your own crafting table block. Then you have to tell your CraftingTable block to open your custom container instead of the vanilla one. You can see how vanilla opens the WorkbenchContainer by looking inside the CraftingTableBlock class. I don't know if this is the best way to achieve this though, there may be a better way

Edited by Beethoven92
  • Like 1

Check out the port of the BetterEnd fabric mod (WIP): https://www.curseforge.com/minecraft/mc-mods/betterend-forge-port

Link to comment
Share on other sites

41 minutes ago, Beethoven92 said:

Mmmm it seems you did not folllow the advice of Draco18s, which i'll quote here:

Your block extends the vanilla CraftingTableBlock class, but its not the vanilla crafting table itself (Blocks.CRAFTING_TABLE)...the vanilla crafting table container checks for the player proximity only with the Block.CRAFTING_TABLE, so of course your block doesn't satisfy the condition for the container to open. I think you would need to create a custom container which extends WorkbenchContainer and override the canInteractWith method to check for proximity with your own crafting table block. Then you have to tell your CraftingTable block to open your custom container instead of the vanilla one. You can see how vanilla opens the WorkbenchContainer by looking inside the CraftingTableBlock class. I don't know if this is the best way to achieve this though, there may be a better way

I think you gave me an idea what I can do about it, thanks for your answer, I will update this topic later to report if it worked or not

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