I'm attempting to play a sound when a player right clicks a block with a tool. It works fine if I place the block in creative, however when the block is generated with the world or I leave and return, the sound does not play due to a value comparison with NBT. I understand I can use packets, but is their an easier way to a ) read the NBT on the client side or b ) play the sound to all players via the server? I would prefer to let all players hear the sound
Edit: So I found a solution: the NBT comparison updates the blockstate during the comparison, so I just use the blockstate because it's synced to compare. The original question still stands, however.
Forge's documentation explains how the various sound-playing methods work here. If the client doesn't have the required data, just play the sound from the server (passing null as the player argument). If the client does have the data, play the sound on both sides (passing the player as the player argument).
If you need TileEntity data synced to the client, override TileEntity#getUpdateTag, TileEntity#getUpdatePacket and TileEntity#onDataPacket.
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.
I'm attempting to play a sound when a player right clicks a block with a tool. It works fine if I place the block in creative, however when the block is generated with the world or I leave and return, the sound does not play due to a value comparison with NBT. I understand I can use packets, but is their an easier way to a ) read the NBT on the client side or b ) play the sound to all players via the server? I would prefer to let all players hear the sound
Edit: So I found a solution: the NBT comparison updates the blockstate during the comparison, so I just use the blockstate because it's synced to compare. The original question still stands, however.
The creator of Oria (comming soon (don't count on it (undertale reference)))
Forge's documentation explains how the various sound-playing methods work here. If the client doesn't have the required data, just play the sound from the server (passing null as the player argument). If the client does have the data, play the sound on both sides (passing the player as the player argument).
If you need TileEntity data synced to the client, override TileEntity#getUpdateTag, TileEntity#getUpdatePacket and TileEntity#onDataPacket.
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.