Search in sources :

Example 1 with ClientboundBlockEntityDataPacket

use of net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket in project Balm by ModdingForBlockheads.

the class BalmBlockEntity method balmSync.

@Override
public void balmSync() {
    if (level != null && !level.isClientSide) {
        List<? extends Player> playerList = level.players();
        ClientboundBlockEntityDataPacket updatePacket = getUpdatePacket();
        if (updatePacket == null) {
            return;
        }
        for (Object obj : playerList) {
            ServerPlayer player = (ServerPlayer) obj;
            if (Math.hypot(player.getX() - worldPosition.getX() + 0.5, player.getZ() - worldPosition.getZ() + 0.5) < 64) {
                player.connection.send(updatePacket);
            }
        }
    }
}
Also used : ClientboundBlockEntityDataPacket(net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket) ServerPlayer(net.minecraft.server.level.ServerPlayer)

Aggregations

ClientboundBlockEntityDataPacket (net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket)1 ServerPlayer (net.minecraft.server.level.ServerPlayer)1