Posted March 1, 201510 yr A block in my mod has a texture for on and off but it will only update when the GUI is open. the block code can be found here: https://github.com/danielm59/Fast-Food/blob/master/src/main/java/danielm59/fastfood/block/BlockChurn.java the tile entity code can be found here: https://github.com/danielm59/Fast-Food/blob/master/src/main/java/danielm59/fastfood/tileentity/TileEntityChurn.java
March 2, 201510 yr Hi The rendering instructions for Blocks are only updated when necessary. If you update the information, you need to trigger a block update. Or alternatively, if your blockstate is only used for rendering, change the rendering to a TileEntitySpecialRenderer instead of a BlockModel. For more information see here (first few paragraphs) http://greyminecraftcoder.blogspot.com.au/2014/12/block-rendering-18.html -TGG
March 3, 201510 yr Hi This snippet should do the trick I think worldObj.markBlockForUpdate(blockPos); You should only call it when something is changed. -TGG
March 3, 201510 yr Author I already have that line in my TE update code but only get called when the GUI is open, where else should i have.
March 4, 201510 yr I already have that line in my TE update code but only get called when the GUI is open, where else should i have. Whenever something turns your block on or off, at a guess. Or have I misunderstood your question? -TGG
March 4, 201510 yr Author I have code I think should work which uses the function you said but I can not work out why it only updates when the GUI is open.
March 4, 201510 yr Have you verified that your update code is being called and the right parts are being executed (especially - the call to worldObj.markBlockForUpdate(blockPos)); i.e. using System.out.println() ? -TGG
March 4, 201510 yr Author using debug mode i have seen that the code is only run when the GUI is open but don't know why. I can't do any work with the code until tomorrow evening due to work commitments.
March 5, 201510 yr Author My code runs in update() from IUpdatePlayerListBox. Is this the wrong place?
March 6, 201510 yr yes, that should be the right place I think. I'm not sure why update() would only be called when the GUI is open, doesn't make sense to me at all. -TGG
March 6, 201510 yr Author It looks like my currentProcessTime does not update when the GUI is closed. Do I need to use a packet?
March 6, 201510 yr Hi Could you create a branch which I can fork to test myself? I'm intrigued now. -TGG
March 7, 201510 yr dHi I added some troubleshooting code @Override public void update() { System.out.println("TileEntityChurn.update(): side:" + (worldObj.isRemote ? "client" : "server") + " currentProcessTime:" + currentProcessTime); protected void checkUpdate() { System.out.print(" TileEntityChurn.checkUpdate(): isActive()=" + isActive() + ", activeUpdate=" + activeUpdate); if (isActive() != activeUpdate) { activeUpdate = isActive(); System.out.print(" -> block updated"); update() is called fine on both client and server. The problem is in your client <--> server logic; see the debug output here [10:52:53] [server thread/INFO] [sTDOUT]: [danielm59.fastfood.tileentity.TileEntityChurn:update:31]: TileEntityChurn.update(): side:server currentProcessTime:96 [10:52:53] [Client thread/INFO] [sTDOUT]: [danielm59.fastfood.tileentity.TileEntityChurn:update:31]: TileEntityChurn.update(): side:client currentProcessTime:25 TileEntityChurn.checkUpdate(): isActive()=true, activeUpdate=true [10:52:53] [server thread/INFO] [sTDOUT]: [danielm59.fastfood.tileentity.TileEntityChurn:update:31]: TileEntityChurn.update(): side:server currentProcessTime:97 [10:52:53] [Client thread/INFO] [sTDOUT]: [danielm59.fastfood.tileentity.TileEntityChurn:update:31]: TileEntityChurn.update(): side:client currentProcessTime:25 TileEntityChurn.checkUpdate(): isActive()=true, activeUpdate=true [10:52:53] [server thread/INFO] [sTDOUT]: [danielm59.fastfood.tileentity.TileEntityChurn:update:31]: TileEntityChurn.update(): side:server currentProcessTime:98 [10:52:53] [Client thread/INFO] [sTDOUT]: [danielm59.fastfood.tileentity.TileEntityChurn:update:31]: TileEntityChurn.update(): side:client currentProcessTime:25 TileEntityChurn.checkUpdate(): isActive()=true, activeUpdate=true [10:52:53] [Client thread/INFO] [sTDOUT]: [danielm59.fastfood.tileentity.TileEntityChurn:update:31]: TileEntityChurn.update(): side:client currentProcessTime:25 TileEntityChurn.checkUpdate(): isActive()=true, activeUpdate=true [10:52:53] [server thread/INFO] [sTDOUT]: [danielm59.fastfood.tileentity.TileEntityChurn:update:31]: TileEntityChurn.update(): side:server currentProcessTime:99 [10:52:54] [server thread/INFO] [sTDOUT]: [danielm59.fastfood.tileentity.TileEntityChurn:update:31]: TileEntityChurn.update(): side:server currentProcessTime:0 [10:52:54] [Client thread/INFO] [sTDOUT]: [danielm59.fastfood.tileentity.TileEntityChurn:update:31]: TileEntityChurn.update(): side:client currentProcessTime:25 TileEntityChurn.checkUpdate(): isActive()=true, activeUpdate=true [10:52:54] [server thread/INFO] [sTDOUT]: [danielm59.fastfood.tileentity.TileEntityChurn:update:31]: TileEntityChurn.update(): side:server currentProcessTime:0 [10:52:54] [Client thread/INFO] [sTDOUT]: [danielm59.fastfood.tileentity.TileEntityChurn:update:31]: TileEntityChurn.update(): side:client currentProcessTime:25 TileEntityChurn.checkUpdate(): isActive()=true, activeUpdate=true [10:52:54] [server thread/INFO] [sTDOUT]: [danielm59.fastfood.tileentity.TileEntityChurn:update:31]: TileEntityChurn.update(): side:server currentProcessTime:0 [10:52:54] [Client thread/INFO] [sTDOUT]: [danielm59.fastfood.tileentity.TileEntityChurn:update:31]: TileEntityChurn.update(): side:client currentProcessTime:25 TileEntityChurn.checkUpdate(): isActive()=true, activeUpdate=true [10:52:54] [Client thread/INFO] [sTDOUT]: [danielm59.fastfood.tileentity.TileEntityChurn:update:31]: TileEntityChurn.update(): side:client currentProcessTime:25 TileEntityChurn.checkUpdate(): isActive()=true, activeUpdate=true [10:52:54] [server thread/INFO] [sTDOUT]: [danielm59.fastfood.tileentity.TileEntityChurn:update:31]: TileEntityChurn.update(): side:server currentProcessTime:0 [10:52:54] [server thread/INFO] [sTDOUT]: [danielm59.fastfood.tileentity.TileEntityChurn:update:31]: TileEntityChurn.update(): side:server currentProcessTime:0 [10:52:54] [Client thread/INFO] [sTDOUT]: [danielm59.fastfood.tileentity.TileEntityChurn:update:31]: TileEntityChurn.update(): side:client currentProcessTime:25 TileEntityChurn.checkUpdate(): isActive()=true, activeUpdate=true You update the server currentProcessTime but not the client, but only the client does anything about it. markDirty is no guarantee. even markBlockForUpdate on the server doesn't automatically update the client immediately. I suggest you put the incrementing logic on the client side as well. Actually I think it could probably be identical to the server side, since the containers will re-sync when you open them to retrieve your butter. Try it and see? I've committed my modified forked version and it seems to work fine. -TGG
March 7, 201510 yr Author That doesn't work when you put milk or butter in with a hopper. The client is not updating. My code is in the churn texture branch
March 7, 201510 yr I updated the churn texture branch of my fork (master too, by mistake). See this commit https://github.com/TheGreyGhost/Fast-Food/commit/e6c13294fc40a5e81c29665a8caa496d99ce8a4e It works fine for me. When I put either milk or butter into the churn, close the GUI, and wait for a few seconds, the top of the block changes from yellow/white back to black. copied code: package danielm59.fastfood.tileentity; import danielm59.fastfood.recipe.ChurnRecipe; import danielm59.fastfood.recipe.ChurnRegistry; import net.minecraft.item.ItemStack; import net.minecraft.server.gui.IUpdatePlayerListBox; public class TileEntityChurn extends TileEntityFF implements IUpdatePlayerListBox { public int currentProcessTime; public boolean activeUpdate; public TileEntityChurn() { super(); inventory = new ItemStack[2]; } @Override public String getName() { return "Churn"; } @Override public void update() { System.out.println("TileEntityChurn.update(): side:" + (worldObj.isRemote ? "client" : "server") + " currentProcessTime:" + currentProcessTime); if (true) {// (!worldObj.isRemote) { ChurnRecipe recipe = ChurnRegistry.getInstance().getMatchingRecipe(inventory[0], inventory[1]); if (recipe != null) { if (++currentProcessTime >= 100) { this.markDirty(); currentProcessTime = 0; if (inventory[1] != null) { inventory[1].stackSize += recipe.getOutput().stackSize; } else { inventory[1] = recipe.getOutput().copy(); } if (inventory[0].getItem().hasContainerItem()) { setInventorySlotContents(0, new ItemStack(inventory[0].getItem().getContainerItem())); } else { decrStackSize(0, 1); } } } else { currentProcessTime = 0; } } else { // checkUpdate(); } checkUpdate(); } protected void checkUpdate() { System.out.print(" TileEntityChurn.checkUpdate(): isActive()=" + isActive() + ", activeUpdate=" + activeUpdate); if (isActive() != activeUpdate) { activeUpdate = isActive(); System.out.print(" -> block updated"); worldObj.notifyBlockOfStateChange(pos, worldObj.getBlockState(pos).getBlock()); worldObj.markBlockForUpdate(pos); } System.out.println(); } public boolean isActive() { boolean active = (currentProcessTime>0); return active; } public float getProgress() { return (float) currentProcessTime/100; } } -TGG
March 7, 201510 yr Author That is what I tried but when you use a hopper to input the item the texture only updates once the GUI has been opened.
March 7, 201510 yr Hi Hmmm, sounds like the hopper is doing something on the server but not communicating it to the client. I don't know how hoppers work, sorry, you could try putting a breakpoint into TileEntityHopper.func_145883_k() to see what happens when the hopper inserts an object into your inventory, and figure out how to make it update the blockstate on the client so you can see it. -TGG
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.