Jump to content

Recommended Posts

Posted

Hey guys.

 

So, I've got an item. In the item's class, I have this which is called when the player right-clicks with the item in hand.

 

	if (!world.isRemote) {
        if (player.isSneaking()) {
            System.out.println("Add to cooked value");
            item.stackTagCompound.setFloat("cookedValue", (item.stackTagCompound.getFloat("cookedValue") + 1));
        }
	}

 

and it works great, exactly as intended.

 

However, when I put the same code into my Tile Entities updateEntity() method (item.stackTagCompound.setFloat("cookedValue", (item.stackTagCompound.getFloat("cookedValue") + 1));) it does nothing. I have a println by it, which is called, but the actual value isn't changed.

 

Anyone got any suggestions as to what I'm doing wrong? :)

 

 

width=463 height=200

http://s13.postimg.org/z9mlly2av/siglogo.png[/img]

My mods (Links coming soon)

Cities | Roads | Remula | SilvaniaMod | MoreStats

Posted

Could you post your full updateEntity method?

 

Not sure how it makes any difference but sure:

@Override
public void updateEntity() {
	ItemStack fuel = getStackInSlot(0);
	ItemStack hob1 = getStackInSlot(1);
	ItemStack hob2 = getStackInSlot(2);
	ItemStack hob3 = getStackInSlot(3);
	ItemStack hob4 = getStackInSlot(4);
	ItemStack grill1 = getStackInSlot(5);
	ItemStack oven1 = getStackInSlot(6);
	ItemStack oven2 = getStackInSlot(7);
	int fuelVal = 10000;
	if (fuelVal > 0) {
		//Temperature Setting for each section affects cook speed.
		//Grill 1
		if (grill1 != null) {
			if (temperature >= grill1Setting) {
				if (grill1.getItem() instanceof IFlenixFoods) {
					NBTTagCompound grill1Tag = grill1.getTagCompound();
					if (grill1Tag == null) {
						grill1 = initNBT(grill1);
					}
					float localCV = 0.0F;
					float cookedValue = grill1.stackTagCompound.getFloat("cookedValue");
					float maxCV = grill1.stackTagCompound.getFloat("burnedLevel");
					int foodTemp = grill1.stackTagCompound.getInteger("temperature");
					if (foodTemp >= temperature) {
						System.out.println("Add to cooked value: " + cookedValue);
			           		grill1.stackTagCompound.setFloat("cookedValue", cookedValue + 1);
					} else {
						grill1.stackTagCompound.setInteger("temperature", foodTemp + 1);
						System.out.println("Food temp: " + foodTemp);
					}
					if (cookedValue <= maxCV) {
						float cookMultiplier = temperature / 100000;
						fuelValue = fuelValue - (cookMultiplier * 100);
						grill1.stackTagCompound.setFloat("cookedValue", cookedValue + cookMultiplier);
					}
				}
			} else {
				temperature++;
				System.out.println("Temp: " + temperature);
			}
		}
	}
}

 

 

I will point out that other parts of that aren't fully functional, but "Food temp: X" is printed to my log continuously (with X always being the same number regardless of what it's set at)

width=463 height=200

http://s13.postimg.org/z9mlly2av/siglogo.png[/img]

My mods (Links coming soon)

Cities | Roads | Remula | SilvaniaMod | MoreStats

Posted

Under the suggestion of an IRC user, I tried setting the code to the following:

 

						IFlenixFoods food = ((IFlenixFoods) grill1.getItem());
						NBTTagCompound tag = new NBTTagCompound();
						tag.setFloat("cookedValue", cookedValue + 0.01F);
						grill1.stackTagCompound = tag;
						setInventorySlotContents(5, grill1);
						//Slot 5 is temporary for now, because I already check to make sure it's in slot 5. It'll be an if later.

 

This seems to solve the problem of increasing the cookedValue, but at the same time deletes all other saved NBT data; therefore no good.

Anyone got any other ideas?

width=463 height=200

http://s13.postimg.org/z9mlly2av/siglogo.png[/img]

My mods (Links coming soon)

Cities | Roads | Remula | SilvaniaMod | MoreStats

Posted

How did you initialize the stackTagCompound?

I think this problem is related with the problem...

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

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.