Jump to content

Recommended Posts

Posted

Hello peeps. I have found myself facing an issue that requires some assistance.

I am making a class that extends 

GuiScreen

which is the GUI for an item. I need to accomplish 2 things, which *should* be fairly straightforward (he says).

1st: I need the item to be able to store an item. I'm fairly sure this can be done with NBTData, I just need pointing in he right direction, it's been a very long while since I've done anything like that, and I had help.

2nd: I need the GUI to have slots. Now, the item isn't a block, so I'm pretty sure a container is out of the question. I only need 1 slot, and then the hotbar slots (possibly moved to be vertical next to the GUI, possibly not, depends on design choices). That way, the player can insert an item into the slot, and have it stored in the holding item.

 

If anybody can be kind enough to shed light on how to go about doing this, I would greatly appreciate it.

Posted
7 minutes ago, DoctorLOGiQ said:

1st: I need the item to be able to store an item. I'm fairly sure this can be done with NBTData, I just need pointing in he right direction, it's been a very long while since I've done anything like that, and I had help

Capabilities.

7 minutes ago, DoctorLOGiQ said:

2nd: I need the GUI to have slots. Now, the item isn't a block, so I'm pretty sure a container is out of the question. I only need 1 slot, and then the hotbar slots (possibly moved to be vertical next to the GUI, possibly not, depends on design choices). That way, the player can insert an item into the slot, and have it stored in the holding item

...Capabilities, specifically IItemHandler.

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
2 hours ago, DoctorLOGiQ said:

so I'm pretty sure a container is out of the question

No, this is not how a Container works. A Container is essentially a server side GUI that just simply holds the information, such as ItemStacks so that the Client can't cheat. You should be using GuiContainer and Container for this.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted

Yes, I am aware that the container is the server-side item handling system and the GUI is the client-side textures and text.

 

So I've searched around for days and cannot find a reference or a guide to help me get the ItemStack to hold and store data, I'm not even getting close. This capability nonsense it confusing, and with no examples I can't make sense of it. And I've done this before, a long time ago :/ So if one of you could be so kind as to provide a brief and to-the-point run-down of exactly HOW I can set up this system, I think it would help others too. I do not ask this without having spent a lot of time trying my best to figure it out and looking at a LOT of code.

 

And just to be clear, this item has a max stack size of 1, and the item I want it to store is the same. I would like players to be able to have multiple items of the same type with their respective inventories being unique. And thank you for your responses.

Posted
1 minute ago, DoctorLOGiQ said:

And just to be clear, this item has a max stack size of 1, and the item I want it to store is the same. I would like players to be able to have multiple items of the same type with their respective inventories being unique. And thank you for your responses.

It is pretty simple if it is your own Item you wish to add capabilities to it. Override the method initCapabilities in your Item class and handle it exactly like you would a TE. And in your case it sounds like you could just use the IItemHandler capability you do not need to create your own.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted
1 minute ago, Animefan8888 said:

It is pretty simple if it is your own Item you wish to add capabilities to it. Override the method initCapabilities in your Item class and handle it exactly like you would a TE. And in your case it sounds like you could just use the IItemHandler capability you do not need to create your own.

Yes, I have overridden initCapabilities() and added the ItemHandler capability to it already. It's the rest that's giving me a hard time. There was some stuff involving providers in one person's post, but I don't remember ever having to do that last time. I'm having a very hard time remembering how I did this previously, and I don't have the project files any more thanks to Windows deciding to lock and wipe my HDD once.

Posted
1 minute ago, DoctorLOGiQ said:

Yes, I have overridden initCapabilities() and added the ItemHandler capability to it already. It's the rest that's giving me a hard time. There was some stuff involving providers in one person's post, but I don't remember ever having to do that last time. I'm having a very hard time remembering how I did this previously, and I don't have the project files any more thanks to Windows deciding to lock and wipe my HDD once.

Well then what exactly is the problem you are having? Not being able to display the Capabilities data on the client? Is it there on the server? If so you just need to sync it with a packet.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted

The whole capability workflow. I don't understand any of it any more.

 

I just need help understanding how to get this working, from start to finish, so that I can actually make full sense of this and be able to do it again from memory in the future.

Posted
8 minutes ago, DoctorLOGiQ said:

The whole capability workflow. I don't understand any of it any more.

 

I just need help understanding how to get this working, from start to finish, so that I can actually make full sense of this and be able to do it again from memory in the future.

  1. Expose your capability of choice either custom or one of the provided ones. Via Item#initCapabilities or AttachCapabilitiesEvent
  2. Update the client when the capabilities data changes via a custom packet.
  3. Do what ever you want with the data from the capability via an ItemStack instance. ItemStack#getCapability/ItemStack#hasCapability

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

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.