Search in sources :

Example 1 with ClientboundBlockUpdatePacket

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

the class LevelMixin_API method sendBlockChange.

@Override
public void sendBlockChange(final int x, final int y, final int z, final org.spongepowered.api.block.BlockState state) {
    Objects.requireNonNull(state, "state");
    final ClientboundBlockUpdatePacket packet = new ClientboundBlockUpdatePacket(new BlockPos(x, y, z), (BlockState) state);
    ((net.minecraft.world.level.Level) (Object) this).players().stream().filter(ServerPlayer.class::isInstance).map(ServerPlayer.class::cast).forEach(p -> p.connection.send(packet));
}
Also used : ClientboundBlockUpdatePacket(net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket) ServerPlayer(net.minecraft.server.level.ServerPlayer) BlockPos(net.minecraft.core.BlockPos) Level(net.minecraft.world.level.Level)

Example 2 with ClientboundBlockUpdatePacket

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

the class LevelMixin_API method resetBlockChange.

@Override
public void resetBlockChange(final int x, final int y, final int z) {
    final ClientboundBlockUpdatePacket packet = new ClientboundBlockUpdatePacket((LevelReader) this, new BlockPos(x, y, z));
    ((net.minecraft.world.level.Level) (Object) this).players().stream().filter(ServerPlayer.class::isInstance).map(ServerPlayer.class::cast).forEach(p -> p.connection.send(packet));
}
Also used : ClientboundBlockUpdatePacket(net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket) ServerPlayer(net.minecraft.server.level.ServerPlayer) BlockPos(net.minecraft.core.BlockPos) Level(net.minecraft.world.level.Level)

Aggregations

BlockPos (net.minecraft.core.BlockPos)2 ClientboundBlockUpdatePacket (net.minecraft.network.protocol.game.ClientboundBlockUpdatePacket)2 ServerPlayer (net.minecraft.server.level.ServerPlayer)2 Level (net.minecraft.world.level.Level)2