Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Hey guys, I don't know why, but Minecraft sets the NBTTags of two ItemStacks equal. So I mean, I wrote this code:

slots[2].stackTagCompound = slots[1].stackTagCompound

But my problem is, every time I change the NBt from slots[2], it also changes slots[1], I think the solution is really simple and I'm also not new in Java, but sometimes even a good java programer gets stick in something easy java, sorry for that :)

 

public void updateEntity(){ 
	if(slots[2] == null && rh.getWorkingItemGroupBasedRecipe(slots) != -1 && System.currentTimeMillis() -10 > lastCrafted && !(System.currentTimeMillis()-50 > lastCrafted)){
		System.out.println("Gecraftet");
	}

	this.slots[2] = rh.addOutputSlotManagerforItemBase(slots, 2);
	if(rh.getWorkingItemGroupBasedRecipe(slots) != -1){
		lastCrafted = System.currentTimeMillis();
	}
	if(ItemStack.areItemStacksEqual(slots[1], slots[2])){
		System.out.println("Gleich");
	}
	craftingSystem();
	this.openInventory();
}

private void craftingSystem() {

	if(slots[0] != null && slots[1] != null){
		if((slots[0].getItem() == Extrashoes.SingleJetBoot || slots[0].getItem() == Extrashoes.JetBoots) && ItemGroup.isItemPartofItemGroup(slots[1].getItem(), Extrashoes.ModifiableShoesGroup)){
			handleJetStuff();
		}
	}


}

private void handleJetStuff(){

	if(slots[0].getItem() == Extrashoes.SingleJetBoot){
		if(!slots[1].stackTagCompound.getBoolean("Jetboots")){
			if(slots[1] != slots[2]){
				slots[2] = null;
				slots[2] = new ItemStack(Extrashoes.ModifiableShoe[Extrashoes.ModifiableShoesGroup.getNumberofIteminItemGroup(slots[1].getItem(), Extrashoes.ModifiableShoesGroup)]);
				slots[2].stackTagCompound = slots[1].stackTagCompound;
				slots[2].stackTagCompound.setString("TypeofBoot", "golden_boots");
				if(slots[2].stackTagCompound.getBoolean("SingleJetBoot")){

					if(slots[2].stackTagCompound.getDouble("Remaining Weight") > 5){
						slots[2].stackTagCompound.setBoolean("JetBoots", true);
						slots[2].stackTagCompound.setBoolean("SingleJetBoot", false);
						double rw = slots[2].stackTagCompound.getDouble("Remaining Weight");
						slots[2].stackTagCompound.setDouble("Remaining Weight", rw - 5);
					}
				}else{
					if(slots[2].stackTagCompound.getDouble("Remaining Weight") > 5){
						slots[2].stackTagCompound.setBoolean("SingleJetBoot", true);
						double rw = slots[2].stackTagCompound.getDouble("Remaining Weight");
						slots[2].stackTagCompound.setDouble("Remaining Weight", rw - 5);
					}
				}
			}
		}
	}
}

Creator of Extra Shoes

 

Watch out, I'm total jerk, and I'll troll anybody if it feels like its necessary. Pls report me then

  • Author

Take this code:

Object a = new Object();
Object b = a;

 

Both variables point to the same object! Variables are just pointers that point to an Object. If you change that object, all the variables stay the same, they still point to the same object. But of course the contents of the object then has changed in all the variables, because they point to the same thing.

You probably want to create a copy of the NBT, use .copy().

OMG thank you, I really forgot that, now it works thank you :D

 

Creator of Extra Shoes

 

Watch out, I'm total jerk, and I'll troll anybody if it feels like its necessary. Pls report me then

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.