use of net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket in project UniversalGraves by Patbox.
the class GravesLookType method sendHeadToPlayer.
public static void sendHeadToPlayer(ServerPlayerEntity player, BlockPos pos, NbtCompound compound) {
if (compound != null) {
compound.putString("id", "minecraft:skull");
compound.putInt("x", pos.getX());
compound.putInt("y", pos.getY());
compound.putInt("z", pos.getZ());
player.networkHandler.sendPacket(new BlockEntityUpdateS2CPacket(pos, 4, compound));
}
}
use of net.minecraft.network.packet.s2c.play.BlockEntityUpdateS2CPacket in project FastAsyncWorldEdit by IntellectualSites.
the class FabricPlayer method sendFakeBlock.
@Override
public <B extends BlockStateHolder<B>> void sendFakeBlock(BlockVector3 pos, B block) {
World world = getWorld();
if (!(world instanceof FabricWorld)) {
return;
}
BlockPos loc = FabricAdapter.toBlockPos(pos);
if (block == null) {
final BlockUpdateS2CPacket packetOut = new BlockUpdateS2CPacket(((FabricWorld) world).getWorld(), loc);
player.networkHandler.sendPacket(packetOut);
} else {
final BlockUpdateS2CPacket packetOut = new BlockUpdateS2CPacket();
PacketByteBuf buf = new PacketByteBuf(Unpooled.buffer());
buf.writeBlockPos(loc);
buf.writeVarInt(Block.getRawIdFromState(FabricAdapter.adapt(block.toImmutableState())));
try {
packetOut.read(buf);
} catch (IOException e) {
return;
}
player.networkHandler.sendPacket(packetOut);
if (block instanceof BaseBlock && block.getBlockType().equals(BlockTypes.STRUCTURE_BLOCK)) {
final BaseBlock baseBlock = (BaseBlock) block;
final CompoundTag nbtData = baseBlock.getNbtData();
if (nbtData != null) {
player.networkHandler.sendPacket(new BlockEntityUpdateS2CPacket(new BlockPos(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ()), STRUCTURE_BLOCK_PACKET_ID, NBTConverter.toNative(nbtData)));
}
}
}
}
Aggregations