Jump to content

[1.10.2] {Solved} Preventing putting an item in itself


EscapeMC

Recommended Posts

Hello!  ;D

 

So if you all remember from my last thread, you all helped me make an item where on right click, it would bring up a chest-like Gui.

 

Now, I realized I need to make the item not be able to be put in itself... Anyone know how to do that?

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 have a custom slot class, yeah?

Make that slot not accept your bag item.

 

Done.

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 have a custom slot class, yeah?

Make that slot not accept your bag item.

 

Done.

 

What would I be overriding here? canTakeStack? or what else?

 

 

 

EDIT: NEVERMIND xD I found isItemValid. Now, how do I say "test_bag is a no-no"? if(__ = test_bag) return false?

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 have a custom slot class, yeah?

Make that slot not accept your bag item.

 

Done.

 

What would I be overriding here? canTakeStack? or what else?

 

 

 

EDIT: NEVERMIND xD I found isItemValid. Now, how do I say "test_bag is a no-no"? if(__ = test_bag) return false?

Quick question, how much Java do you know, how much Minecraft/Forge do you know?

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

You have a custom slot class, yeah?

Make that slot not accept your bag item.

 

Done.

 

What would I be overriding here? canTakeStack? or what else?

 

 

 

EDIT: NEVERMIND xD I found isItemValid. Now, how do I say "test_bag is a no-no"? if(__ = test_bag) return false?

Quick question, how much Java do you know, how much Minecraft/Forge do you know?

 

I am not too experienced with Java, and I try to learn as much Minecraft/Forge as I can. Everything I have coded I understand (I go back and ask everything to understand it) and I understand some other stuff.

 

Keep in mind, I am only 14, still in 8th grade. I like coding so that's why I am here.

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 just asking, you know what an ItemStack is, right? And do you know what an instanceof check is?

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 just asking, you know what an ItemStack is, right? And do you know what an instanceof check is?

 

Yes I do. Now that you say this, let me see if I can piece together this with new ideas.

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 don't even need InstanceOf here at all.

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 don't even need InstanceOf here at all.

Just in case he wants to make more Bags than just one. This way you can't put any bag inside a bag.

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

You don't even need InstanceOf here at all.

 

What can/should/do I use here then? (I was just experimenting with instanceof and no good, so that's why I ask)

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 don't even need InstanceOf here at all.

 

What can/should/do I use here then? (I was just experimenting with instanceof and no good, so that's why I ask)

How did you use instanceof and you could also use stack.getItem() != bagItemField.

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

I was using something like

 

		instanceof(stack.isItemEqual(ModItems.test_bag)){
	return false;
	}

 

yes, I think this isn't correct (I know test_bag isn't an itemstack, i am trying to figure out what to do there...)

 

Anyway, with that instanceof stuff I think I got it to work with "while"...

 

		while(stack.getItem() != ModItems.test_bag){
	return false;

	}

	return true;

}

 

Is while ok here?

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

instanceof(stack.isItemEqual(ModItems.test_bag))

 

ok, for one, that's not even valid java. and two, even if it was, an ItemStack and an Item will never ever not in a billion years be equal.

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

Ok, so I have

	@Override
public boolean isItemValid(ItemStack stack) {

	if(stack.getItem() != ModItems.test_bag){
	return false;

	}

	return true;

}

 

And this does not work. I can still put my item in there.

 

WAIT!

*Cheeks code once more, sees !=, slams head into desk* Wow I am stupid.

 

Solved

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.