TehStoneMan Posted October 29, 2020 Share Posted October 29, 2020 I have a TileEntity with a custom capability that changes the texture. I have a GUI where the texture can be changed. When the texture is updated, I would like to send a message to any player in the area to re-render the TileEntity with the new texture. I have a message with the required information, but how do I send it? NETWORK.send( PacketDistributor.???.with( () -> ??? ), new UpdateConfigMessage( pos, this ) ) Quote My mods: http://www.curse.com/mc-mods/minecraft/225548-greenscreen http://mods.curse.com/mc-mods/minecraft/238981-cash-craft Link to comment Share on other sites More sharing options...
poopoodice Posted October 29, 2020 Share Posted October 29, 2020 https://mcforge.readthedocs.io/en/latest/networking/simpleimpl/#sending-to-clients Quote Link to comment Share on other sites More sharing options...
TehStoneMan Posted October 30, 2020 Author Share Posted October 30, 2020 Yes, I know about that. If I could find the answer there, I wouldn't be asking here. Quote My mods: http://www.curse.com/mc-mods/minecraft/225548-greenscreen http://mods.curse.com/mc-mods/minecraft/238981-cash-craft Link to comment Share on other sites More sharing options...
TheGreyGhost Posted October 30, 2020 Share Posted October 30, 2020 (edited) You might find this working example useful https://github.com/TheGreyGhost/MinecraftByExample/tree/master/src/main/java/minecraftbyexample/mbe60_network_messages The relevant bit is StartupCommon.simpleChannel.sendToServer(airstrikeMessageToServer); in ItemAirStrike class and for sending to clients // This message is called from the Server thread. // It spawns a random number of the given projectile at a position above the target location static void processMessage(AirstrikeMessageToServer message, ServerPlayerEntity sendingPlayer) { // 1) First send a message to all other clients who are in the same dimension, to tell them to render a "target" // effect on the ground // There are a number of other PacketDistributor types defined for other cases, for example // Sending to one player // simpleChannel.send(PacketDistributor.PLAYER.with(playerMP), new MyMessage()); // // Send to all players tracking this chunk // simpleChannel.send(PacketDistributor.TRACKING_CHUNK.with(chunk), new MyMessage()); // // Sending to all connected players // simpleChannel.send(PacketDistributor.ALL.noArg(), new MyMessage()); TargetEffectMessageToClient msg = new TargetEffectMessageToClient(message.getTargetCoordinates()); RegistryKey<World> playerDimension = sendingPlayer.func_241141_L_(); // func_241141_L_ is getPlayerDimension StartupCommon.simpleChannel.send(PacketDistributor.DIMENSION.with(() -> playerDimension), msg); -TGG Edited October 30, 2020 by TheGreyGhost cut short Quote Link to comment Share on other sites More sharing options...
TehStoneMan Posted October 30, 2020 Author Share Posted October 30, 2020 It doesn't quite work - I don't have access to the player. But I can access the TileEntity that the capability is attached to. public TileEntityReinforcedChest() { super( BetterStorageTileEntityTypes.REINFORCED_CHEST.get() ); config = new HexKeyConfig() { @Override protected void onContentsChanged( int slot ) { TileEntityReinforcedChest.this.markDirty(); BetterStorage.NETWORK.send( PacketDistributor.DIMENSION.with( () -> ??? ), new UpdateConfigMessage( pos, this ) ); } }; } Quote My mods: http://www.curse.com/mc-mods/minecraft/225548-greenscreen http://mods.curse.com/mc-mods/minecraft/238981-cash-craft Link to comment Share on other sites More sharing options...
Recommended Posts
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.