Search in sources :

Example 1 with MessagePlayOutBlockBreakAnimation

use of org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayOutBlockBreakAnimation in project LanternServer by LanternPowered.

the class PlayerInteractionHandler method sendBreakUpdate.

/**
 * TODO: Maybe also send this to the player this handler is attached to for
 * custom break times? Only allowed by faster breaking.
 */
private void sendBreakUpdate(int breakState) {
    final LanternWorld world = this.player.getWorld();
    // noinspection ConstantConditions
    if (world == null) {
        return;
    }
    final Set<LanternPlayer> players = this.player.getWorld().getRawPlayers();
    // Update for all the players except the breaker
    if (players.size() - 1 <= 0) {
        final MessagePlayOutBlockBreakAnimation message = new MessagePlayOutBlockBreakAnimation(this.diggingBlock, this.player.getNetworkId(), breakState);
        players.forEach(player -> {
            if (player != this.player) {
                player.getConnection().send(message);
            }
        });
    }
}
Also used : LanternWorld(org.lanternpowered.server.world.LanternWorld) MessagePlayOutBlockBreakAnimation(org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayOutBlockBreakAnimation)

Aggregations

MessagePlayOutBlockBreakAnimation (org.lanternpowered.server.network.vanilla.message.type.play.MessagePlayOutBlockBreakAnimation)1 LanternWorld (org.lanternpowered.server.world.LanternWorld)1