On my custom furnace for some reason if im watching the GUI and it finishes smelting the progress stops at 0, however if I start smelting and close out of the GUI till its done when I reopen the GUI the progress is stuck between 8-10% till I smelt something else and keep the GUI open then it goes back to 0.
I've had a similar issue before. I don't think it's your TE. It's probably your Container class. If I remember right, I was syncing a progress value too but I found if I exited when the progress was > 0 and came back once it had finished (progress == 0) then it would display the value from before and not 0. This ended up being because my cached value in the Container was always initially 0 so a progress value of 0 was never synced in this situation. Instead I initialised my cached value to -1 so I could detect the 0.
But this isnt just a visual bug in the gui because im using isSmelting to spawn partials and when im in the gui they stop just like they should but if I close out of the gui they dont stop till I smelt something else and keep the GUI open then it it works fine. So to me it sounds like something weird with the isSmelting or maybe my update methods but I cant find anything wrong with them
But this isnt just a visual bug in the gui because im using isSmelting to spawn partials and when im in the gui they stop just like they should but if I close out of the gui they dont stop till I smelt something else and keep the GUI open then it it works fine. So to me it sounds like something weird with the isSmelting or maybe my update methods but I cant find anything wrong with them
No, because remember the Container is updating the TE on the client side. Otherwise, all of the TE's processing should be done on the server side and the client wouldn't be updated unless you do it yourself!
oh my bad I was thinking the TE update method updated the values of the furnace. So I went through and updated everything to the new methods using the MC furnace as a guide, created the fields, moved the getProgressScaled/getPowerRemainingScaled to the GUI and updated the container using the fields method. It worked sort of when I open the gui the progress is at 0, However I missed something like I said I am using isSmelting to spawn partials and they dont stop spawning till I open the gui then it updates and turns them off. and Thanks for the Help
If you sync your data through the Container, it will only update when the player has the GUI open. If you want to sync TileEntity data to the client even when a player doesn't have the GUI open, you need to override TileEntity#getUpdateTag, TileEntity#getUpdatePacket and TileEntity#onDataPacket. williewillus explains this in more detail here.
Alternatively, store this data in the block's state like you were trying to do in your previous thread. This way you don't have to sync the data yourself, just set the state on the server and it will be synced to the appropriate clients.
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
Im willing to learn both ways of doing this and im still looking into the other method but as to updating the TE the prob is theres not a lot of good docs on this but this is what Iv came up with so far still doesnt work but I think im getting closer
@Override
public NBTTagCompound getUpdateTag() {
return writeToNBT(new NBTTagCompound());
}
@Override
public SPacketUpdateTileEntity getUpdatePacket() {
NBTTagCompound nbtTag = new NBTTagCompound();
this.writeToNBT(nbtTag);
return new SPacketUpdateTileEntity(getPos(), 1, nbtTag);
}
@Override
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity packet) {
this.readFromNBT(packet.getNbtCompound());
}
The update packet will only be sent when World#notifyBlockUpdate is called for the block's position.
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
On my custom furnace for some reason if im watching the GUI and it finishes smelting the progress stops at 0, however if I start smelting and close out of the GUI till its done when I reopen the GUI the progress is stuck between 8-10% till I smelt something else and keep the GUI open then it goes back to 0.
Heres my TE
http://pastebin.com/CbtsBtrG
I've had a similar issue before. I don't think it's your TE. It's probably your Container class. If I remember right, I was syncing a progress value too but I found if I exited when the progress was > 0 and came back once it had finished (progress == 0) then it would display the value from before and not 0. This ended up being because my cached value in the Container was always initially 0 so a progress value of 0 was never synced in this situation. Instead I initialised my cached value to -1 so I could detect the 0.
Hope that makes sense
But this isnt just a visual bug in the gui because im using isSmelting to spawn partials and when im in the gui they stop just like they should but if I close out of the gui they dont stop till I smelt something else and keep the GUI open then it it works fine. So to me it sounds like something weird with the isSmelting or maybe my update methods but I cant find anything wrong with them
No, because remember the Container is updating the TE on the client side. Otherwise, all of the TE's processing should be done on the server side and the client wouldn't be updated unless you do it yourself!
oh my bad I was thinking the TE update method updated the values of the furnace. So I went through and updated everything to the new methods using the MC furnace as a guide, created the fields, moved the getProgressScaled/getPowerRemainingScaled to the GUI and updated the container using the fields method. It worked sort of when I open the gui the progress is at 0, However I missed something like I said I am using isSmelting to spawn partials and they dont stop spawning till I open the gui then it updates and turns them off. and Thanks for the Help
block
http://pastebin.com/4cB3EAGE
container
http://pastebin.com/nmDaskpg
tile
http://pastebin.com/fmyWChHL
gui
http://pastebin.com/F3gkAau6
If you sync your data through the Container, it will only update when the player has the GUI open. If you want to sync TileEntity data to the client even when a player doesn't have the GUI open, you need to override TileEntity#getUpdateTag, TileEntity#getUpdatePacket and TileEntity#onDataPacket. williewillus explains this in more detail here.
Alternatively, store this data in the block's state like you were trying to do in your previous thread. This way you don't have to sync the data yourself, just set the state on the server and it will be synced to the appropriate clients.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
Im willing to learn both ways of doing this and im still looking into the other method but as to updating the TE the prob is theres not a lot of good docs on this but this is what Iv came up with so far still doesnt work but I think im getting closer
@Override
public NBTTagCompound getUpdateTag() {
return writeToNBT(new NBTTagCompound());
}
@Override
public SPacketUpdateTileEntity getUpdatePacket() {
NBTTagCompound nbtTag = new NBTTagCompound();
this.writeToNBT(nbtTag);
return new SPacketUpdateTileEntity(getPos(), 1, nbtTag);
}
@Override
public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity packet) {
this.readFromNBT(packet.getNbtCompound());
}
The update packet will only be sent when World#notifyBlockUpdate is called for the block's position.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
Thanks that did it Thanks to all for Helping
BTW heres how I implemented it I just added to my TE update method
if (flag != isSmelting()) {
flag1 = true;
IBlockState state = worldObj.getBlockState(pos);
worldObj.notifyBlockUpdate(pos, state, state, 3);
}