Posted May 10, 201411 yr 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? http://s13.postimg.org/z9mlly2av/siglogo.png[/img] My mods (Links coming soon) Cities | Roads | Remula | SilvaniaMod | MoreStats
May 11, 201411 yr Author 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) http://s13.postimg.org/z9mlly2av/siglogo.png[/img] My mods (Links coming soon) Cities | Roads | Remula | SilvaniaMod | MoreStats
May 12, 201411 yr Author 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? http://s13.postimg.org/z9mlly2av/siglogo.png[/img] My mods (Links coming soon) Cities | Roads | Remula | SilvaniaMod | MoreStats
May 12, 201411 yr 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.