Search in sources :

Example 1 with IPacket

use of net.minecraft.network.IPacket in project Bookshelf by Darkhax-Minecraft.

the class TileEntityBasic method sync.

/**
 * Synchronizes the server state of the tile with all clients tracking it.
 *
 * @param renderUpdate Whether or not a render update should happen as well. Only use this
 *        if you need to change the block model.
 */
public void sync(boolean renderUpdate) {
    if (renderUpdate) {
        this.setChanged();
        final BlockState state = this.getState();
        this.level.sendBlockUpdated(this.worldPosition, state, state, BlockFlags.DEFAULT_AND_RERENDER);
    } else if (this.level instanceof ServerWorld) {
        final IPacket<?> packet = this.getUpdatePacket();
        WorldUtils.sendToTracking((ServerWorld) this.level, this.getChunkPos(), packet, false);
    }
}
Also used : ServerWorld(net.minecraft.world.server.ServerWorld) IPacket(net.minecraft.network.IPacket) BlockState(net.minecraft.block.BlockState)

Aggregations

BlockState (net.minecraft.block.BlockState)1 IPacket (net.minecraft.network.IPacket)1 ServerWorld (net.minecraft.world.server.ServerWorld)1