Jump to content

[1.10.2] {Solved!!!} Right-Click Item for Chest-like GUI


EscapeMC

Recommended Posts

Change readFromNBT to deserializeNBT(NBTBase nbt)

Change writeToNBT to serializeNBT()

 

Wait can you write out exactly what each thing needs to change to because ti still does not work and I have a feeling that I am just doing 1-2 thing(s) wrong.

 

Don't make you Item implement ICapabilitySerializable make a new class that does, then override initCapabilities in your Item class.

 

How should I do this? What should I make this class? (What type?)

I don't think I can get anymore specific than what I said...

And just a class that implements ICapabilitySerializable

And in your ItemBag make a method called initCapabilities()

 

Alright. So I've made this class. I called it "TestBagCapabilities"

Now I created initCapabilities in test_bag. Now what?

 

And the read/write NBT still isn't working..

Two things...

Post your code or if you have a github put it on there and provide a link and every time your code changes update github.

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.

Link to comment
Share on other sites

  • Replies 116
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

GitHub: https://github.com/EscapeMC/ThingsMod-1.10.2/tree/master/src/main

 

sorry i totally forgot about code

I Love To Help People. Unless They Are The Kind Of People Who Just Doesn't Know Anything. Those People Need Some Serious Help. This Could Help But......

https://www.youtube.com/watch?v=6t0GlXWx_PY

 

ThingsMod Git: https://github.com/EscapeMC/Things-Mod-1.10.2

 

TeamMadness Mod Git: https://github.com/EscapeMC/TeamMadness-Mod-1.10.2

 

If I somehow help you, please click the "Thank You" button. If I am a total waste of time, please click the "Applaud" button.

Link to comment
Share on other sites

Remove

public NBTTagCompound serializeNBT(NBTBase nbt) {
	super.serializeNBT();
	compound.setTag("inputSlot", inputSlot.serializeNBT());

	return compound;
}


@Override
public void deserializeNBT(NBTBase nbt) {
	inputSlot.deserializeNBT(nbt.getCompoundTag("inputSlot"));
}

From your item_bag.

Move

protected ItemStackHandler inputSlot;

from your item_bag to your TestBagCapabilities

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.

Link to comment
Share on other sites

Remove

public NBTTagCompound serializeNBT(NBTBase nbt) {
	super.serializeNBT();
	compound.setTag("inputSlot", inputSlot.serializeNBT());

	return compound;
}


@Override
public void deserializeNBT(NBTBase nbt) {
	inputSlot.deserializeNBT(nbt.getCompoundTag("inputSlot"));
}

From your item_bag.

Move

protected ItemStackHandler inputSlot;

from your item_bag to your TestBagCapabilities

 

Alright, so I've done that. Should I also move

		inputSlot = new ItemStackHandler(18);

to ItemBagCapabilities?

 

And then, what do I do with the 4 methods in IBC? (ItemBagCapabilities)

I Love To Help People. Unless They Are The Kind Of People Who Just Doesn't Know Anything. Those People Need Some Serious Help. This Could Help But......

https://www.youtube.com/watch?v=6t0GlXWx_PY

 

ThingsMod Git: https://github.com/EscapeMC/Things-Mod-1.10.2

 

TeamMadness Mod Git: https://github.com/EscapeMC/TeamMadness-Mod-1.10.2

 

If I somehow help you, please click the "Thank You" button. If I am a total waste of time, please click the "Applaud" button.

Link to comment
Share on other sites

Alright, so I've done that. Should I also move

		inputSlot = new ItemStackHandler(18);

to ItemBagCapabilities?

Yes.

And then, what do I do with the 4 methods in IBC? (ItemBagCapabilities)

Deserialize and Serialize are your read and write. So you load and save your ItemStackHandler with those.

The hasCapability you had before works. The getCapability needs to check if the capability parameter is CapabilityItemHandler.ITEM_HANDLER_CAPABILITY and then return your ItemStackHandler.

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.

Link to comment
Share on other sites

Ok, so I've updated my github once more. Did I get the read and write stuff correct?

I Love To Help People. Unless They Are The Kind Of People Who Just Doesn't Know Anything. Those People Need Some Serious Help. This Could Help But......

https://www.youtube.com/watch?v=6t0GlXWx_PY

 

ThingsMod Git: https://github.com/EscapeMC/Things-Mod-1.10.2

 

TeamMadness Mod Git: https://github.com/EscapeMC/TeamMadness-Mod-1.10.2

 

If I somehow help you, please click the "Thank You" button. If I am a total waste of time, please click the "Applaud" button.

Link to comment
Share on other sites

Ok, so I've updated my github once more. Did I get the read and write stuff correct?

No your serialize needs to write to the NBTBase not read from it.

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.

Link to comment
Share on other sites

Ok, so I've updated my github once more. Did I get the read and write stuff correct?

No your serialize needs to write to the NBTBase not read from it.

 

So just

	public void serializeNBT(NBTBase nbt) {
	inputSlot.serializeNBT();

}

 

?

I Love To Help People. Unless They Are The Kind Of People Who Just Doesn't Know Anything. Those People Need Some Serious Help. This Could Help But......

https://www.youtube.com/watch?v=6t0GlXWx_PY

 

ThingsMod Git: https://github.com/EscapeMC/Things-Mod-1.10.2

 

TeamMadness Mod Git: https://github.com/EscapeMC/TeamMadness-Mod-1.10.2

 

If I somehow help you, please click the "Thank You" button. If I am a total waste of time, please click the "Applaud" button.

Link to comment
Share on other sites

Not quite you need to do

((NBTTagCompound)nbt).setTag("inputSlot", inputSlot.serialize());

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.

Link to comment
Share on other sites

Not quite you need to do

((NBTTagCompound)nbt).setTag("inputSlot", inputSlot.serialize());

 

Says I need a return statement... What should it be? Null?

	public NBTBase serializeNBT(NBTBase nbt) {
	((NBTTagCompound)nbt).setTag("inputSlot", inputSlot.serializeNBT());

}

@Override
public void deserializeNBT(NBTBase nbt) {
	inputSlot.deserializeNBT(((NBTTagCompound) nbt).getCompoundTag("inputSlot"));


}

 

That's the whole right now.

I Love To Help People. Unless They Are The Kind Of People Who Just Doesn't Know Anything. Those People Need Some Serious Help. This Could Help But......

https://www.youtube.com/watch?v=6t0GlXWx_PY

 

ThingsMod Git: https://github.com/EscapeMC/Things-Mod-1.10.2

 

TeamMadness Mod Git: https://github.com/EscapeMC/TeamMadness-Mod-1.10.2

 

If I somehow help you, please click the "Thank You" button. If I am a total waste of time, please click the "Applaud" button.

Link to comment
Share on other sites

return nbt.

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.

Link to comment
Share on other sites

return nbt.

 

Alright, so I do that, but it says I then need to add unimplemented methods, and that method is the same thing. serialize nbt. I added @Override, but it then says remove it.

 

I updated github: https://github.com/EscapeMC/ThingsMod-1.10.2

I Love To Help People. Unless They Are The Kind Of People Who Just Doesn't Know Anything. Those People Need Some Serious Help. This Could Help But......

https://www.youtube.com/watch?v=6t0GlXWx_PY

 

ThingsMod Git: https://github.com/EscapeMC/Things-Mod-1.10.2

 

TeamMadness Mod Git: https://github.com/EscapeMC/TeamMadness-Mod-1.10.2

 

If I somehow help you, please click the "Thank You" button. If I am a total waste of time, please click the "Applaud" button.

Link to comment
Share on other sites

return nbt.

 

Alright, so I do that, but it says I then need to add unimplemented methods, and that method is the same thing. serialize nbt. I added @Override, but it then says remove it.

 

I updated github: https://github.com/EscapeMC/ThingsMod-1.10.2

Remove the parameter in serializeNBT and create a local field of NBTBase and use that one and set it equal to a new NBTTagCompound.

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.

Link to comment
Share on other sites

return nbt.

 

Alright, so I do that, but it says I then need to add unimplemented methods, and that method is the same thing. serialize nbt. I added @Override, but it then says remove it.

 

I updated github: https://github.com/EscapeMC/ThingsMod-1.10.2

Remove the parameter in serializeNBT and create a local field of NBTBase and use that one and set it equal to a new NBTTagCompound.

 

Ok, it took some figuring out, (and some sleep) but I think I've got the NBT part of this:

https://github.com/EscapeMC/ThingsMod-1.10.2/blob/master/src/main/java/com/github/escapemc/thingsmod/items/TestBagCapabilities.java#L35

 

Then also, on that link, look up slightly. Would that be correct for both the hasCapability and getCapability?

 

 

I Love To Help People. Unless They Are The Kind Of People Who Just Doesn't Know Anything. Those People Need Some Serious Help. This Could Help But......

https://www.youtube.com/watch?v=6t0GlXWx_PY

 

ThingsMod Git: https://github.com/EscapeMC/Things-Mod-1.10.2

 

TeamMadness Mod Git: https://github.com/EscapeMC/TeamMadness-Mod-1.10.2

 

If I somehow help you, please click the "Thank You" button. If I am a total waste of time, please click the "Applaud" button.

Link to comment
Share on other sites

return nbt.

 

Alright, so I do that, but it says I then need to add unimplemented methods, and that method is the same thing. serialize nbt. I added @Override, but it then says remove it.

 

I updated github: https://github.com/EscapeMC/ThingsMod-1.10.2

Remove the parameter in serializeNBT and create a local field of NBTBase and use that one and set it equal to a new NBTTagCompound.

 

Ok, it took some figuring out, (and some sleep) but I think I've got the NBT part of this:

https://github.com/EscapeMC/ThingsMod-1.10.2/blob/master/src/main/java/com/github/escapemc/thingsmod/items/TestBagCapabilities.java#L35

 

Then also, on that link, look up slightly. Would that be correct for both the hasCapability and getCapability?

getCapability and hasCapability are indeed correct, but your serializeNBT is not you need a local field not a global field for your NBTBase.

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.

Link to comment
Share on other sites

return nbt.

 

Alright, so I do that, but it says I then need to add unimplemented methods, and that method is the same thing. serialize nbt. I added @Override, but it then says remove it.

 

I updated github: https://github.com/EscapeMC/ThingsMod-1.10.2

Remove the parameter in serializeNBT and create a local field of NBTBase and use that one and set it equal to a new NBTTagCompound.

 

Ok, it took some figuring out, (and some sleep) but I think I've got the NBT part of this:

https://github.com/EscapeMC/ThingsMod-1.10.2/blob/master/src/main/java/com/github/escapemc/thingsmod/items/TestBagCapabilities.java#L35

 

Then also, on that link, look up slightly. Would that be correct for both the hasCapability and getCapability?

getCapability and hasCapability are indeed correct, but your serializeNBT is not you need a local field not a global field for your NBTBase.

 

I click create local field and that is what it gives me.

 

 

Ok, also,

1) What do I put in the initCapabilities of my test_bag?

 

2) What do I need to put in the GuiHandler for getServerGuiElement and getClientGuiElement? I have done this before with my chest, but it was a tileentity.

 

3) What (event?) do I need to do for onItemRightClick ( this.onItemRightClick(itemStackIn, worldIn, playerIn, hand)) to bring up the gui?

I Love To Help People. Unless They Are The Kind Of People Who Just Doesn't Know Anything. Those People Need Some Serious Help. This Could Help But......

https://www.youtube.com/watch?v=6t0GlXWx_PY

 

ThingsMod Git: https://github.com/EscapeMC/Things-Mod-1.10.2

 

TeamMadness Mod Git: https://github.com/EscapeMC/TeamMadness-Mod-1.10.2

 

If I somehow help you, please click the "Thank You" button. If I am a total waste of time, please click the "Applaud" button.

Link to comment
Share on other sites

Global is a field created in the class, while local field is a field created in {} which can only be used inside of those "{}".

public void initCapabilities() {
}

Not the correct method; we told you to override the method called initCapabilities.

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.

Link to comment
Share on other sites

Global is a field created in the class, while local field is a field created in {} which can only be used inside of those "{}".

 

Ok, so do

		NBTTagCompound NBTBase = ____ (what);

in that serializeNBT.

 

public void initCapabilities() {
}

Not the correct method; we told you to override the method called initCapabilities.

Wait so then what do I need to do? I know its not as simple as adding @Override...

I Love To Help People. Unless They Are The Kind Of People Who Just Doesn't Know Anything. Those People Need Some Serious Help. This Could Help But......

https://www.youtube.com/watch?v=6t0GlXWx_PY

 

ThingsMod Git: https://github.com/EscapeMC/Things-Mod-1.10.2

 

TeamMadness Mod Git: https://github.com/EscapeMC/TeamMadness-Mod-1.10.2

 

If I somehow help you, please click the "Thank You" button. If I am a total waste of time, please click the "Applaud" button.

Link to comment
Share on other sites

NBTTagCompound NBTBase = new NBTTagCompound();

And

@Override
public ICapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt) {
	return new CustomCapabilityProvider...
}

Please use your IDE.

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.

Link to comment
Share on other sites

NBTTagCompound NBTBase = new NBTTagCompound();

And

@Override
public ICapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt) {
	return new CustomCapabilityProvider...
}

Please use your IDE.

 

OK, so thi:

	@Override
public ICapabilityProvider initCapabilities(ItemStack stack, NBTTagCompound nbt) {
	return new TestBagCapabilities();
}	

 

Lastly:

 

		this.onItemRightClick(itemStackIn, worldIn, playerIn, hand)

 

What do I need to put in each of the slots? (itemStackIn, worldIn, playerIn, hand)

Please, don't just say itemStackIn, worldIn, playerIn, and hand. I am not sure what exactly these mean in this case

I Love To Help People. Unless They Are The Kind Of People Who Just Doesn't Know Anything. Those People Need Some Serious Help. This Could Help But......

https://www.youtube.com/watch?v=6t0GlXWx_PY

 

ThingsMod Git: https://github.com/EscapeMC/Things-Mod-1.10.2

 

TeamMadness Mod Git: https://github.com/EscapeMC/TeamMadness-Mod-1.10.2

 

If I somehow help you, please click the "Thank You" button. If I am a total waste of time, please click the "Applaud" button.

Link to comment
Share on other sites

Why are you calling onItemRightClick yourself?

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.

Link to comment
Share on other sites

Why are you calling onItemRightClick yourself?

 

I am trying to pull up a Gui (already set up, just once problem with the GuiHandler)

I Love To Help People. Unless They Are The Kind Of People Who Just Doesn't Know Anything. Those People Need Some Serious Help. This Could Help But......

https://www.youtube.com/watch?v=6t0GlXWx_PY

 

ThingsMod Git: https://github.com/EscapeMC/Things-Mod-1.10.2

 

TeamMadness Mod Git: https://github.com/EscapeMC/TeamMadness-Mod-1.10.2

 

If I somehow help you, please click the "Thank You" button. If I am a total waste of time, please click the "Applaud" button.

Link to comment
Share on other sites

You still don't call the method yourself.  You need to override the method so that it does what you want when called.

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.

Link to comment
Share on other sites

You still don't call the method yourself.  You need to override the method so that it does what you want when called.

 

Alright so how would I use it to open my Gui?

 

https://github.com/EscapeMC/ThingsMod-1.10.2/blob/master/src/main/java/com/github/escapemc/thingsmod/items/test_bag.java#L35 ?

 

And then can you look at the capabilities and make sure I've got it right?

I Love To Help People. Unless They Are The Kind Of People Who Just Doesn't Know Anything. Those People Need Some Serious Help. This Could Help But......

https://www.youtube.com/watch?v=6t0GlXWx_PY

 

ThingsMod Git: https://github.com/EscapeMC/Things-Mod-1.10.2

 

TeamMadness Mod Git: https://github.com/EscapeMC/TeamMadness-Mod-1.10.2

 

If I somehow help you, please click the "Thank You" button. If I am a total waste of time, please click the "Applaud" button.

Link to comment
Share on other sites

Ok, so in the GuiHandler, what do I need to put because it is not a TE?

I Love To Help People. Unless They Are The Kind Of People Who Just Doesn't Know Anything. Those People Need Some Serious Help. This Could Help But......

https://www.youtube.com/watch?v=6t0GlXWx_PY

 

ThingsMod Git: https://github.com/EscapeMC/Things-Mod-1.10.2

 

TeamMadness Mod Git: https://github.com/EscapeMC/TeamMadness-Mod-1.10.2

 

If I somehow help you, please click the "Thank You" button. If I am a total waste of time, please click the "Applaud" button.

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.