Search in sources :

Example 1 with ClientboundSetChunkCacheRadiusPacket

use of net.minecraft.network.protocol.game.ClientboundSetChunkCacheRadiusPacket in project SpongeCommon by SpongePowered.

the class PrimaryLevelDataMixin method bridge$setViewDistance.

@Override
public void bridge$setViewDistance(@Nullable final Integer viewDistance) {
    this.impl$viewDistance = viewDistance;
    final ServerLevel world = this.bridge$world();
    if (world != null) {
        final int actual = viewDistance == null ? BootstrapProperties.viewDistance : viewDistance;
        world.getChunkSource().setViewDistance(actual);
        final ClientboundSetChunkCacheRadiusPacket packet = new ClientboundSetChunkCacheRadiusPacket(actual);
        world.players().forEach(p -> p.connection.send(packet));
    }
}
Also used : ServerLevel(net.minecraft.server.level.ServerLevel) ClientboundSetChunkCacheRadiusPacket(net.minecraft.network.protocol.game.ClientboundSetChunkCacheRadiusPacket)

Aggregations

ClientboundSetChunkCacheRadiusPacket (net.minecraft.network.protocol.game.ClientboundSetChunkCacheRadiusPacket)1 ServerLevel (net.minecraft.server.level.ServerLevel)1