use of net.minecraft.network.protocol.game.ClientboundSectionBlocksUpdatePacket in project NotQuests by AlessioGr.
the class PacketInjector method spawnBeaconBeam.
public void spawnBeaconBeam(Player player, Location location) {
// Prepare Data
Connection connection = getConnection(getServerPlayer(player).connection);
location = location.clone();
BlockPos blockPos = new BlockPos(location.getX(), location.getY(), location.getZ());
Chunk chunk = location.getChunk();
CraftChunk craftChunk = (CraftChunk) chunk;
LevelChunk levelChunk = craftChunk.getHandle();
World world = location.getWorld();
CraftWorld craftWorld = (CraftWorld) world;
ServerLevel serverLevel = craftWorld.getHandle();
//
BlockState blockState = location.getBlock().getState();
blockState.setType(Material.BEACON);
SectionPos sectionPos = SectionPos.of((int) location.getX(), (int) location.getY(), (int) location.getZ());
ShortSet positions = ShortSet.of((short) 0);
// PalettedContainer<BlockState> pcB = new PalettedContainer<>();
// net.minecraft.world.level.block.state.BlockState[] presetBlockStates = serverLevel.chunkPacketBlockController.getPresetBlockStates(world, chunkPos, b0 << 4);
// PalettedContainer<BlockState> datapaletteblock = new PalettedContainer<>(net.minecraft.world.level.block.Block.BLOCK_STATE_REGISTRY, Blocks.AIR.defaultBlockState(), PalettedContainer.Strategy.SECTION_STATES, presetBlockStates);
LevelChunkSection section = levelChunk.getHighestSection();
ClientboundSectionBlocksUpdatePacket clientboundSectionBlocksUpdatePacket = new ClientboundSectionBlocksUpdatePacket(sectionPos, positions, section, true);
main.sendMessage(player, "<main>Sending packet...");
connection.send(clientboundSectionBlocksUpdatePacket);
main.sendMessage(player, "<success>Packet sent!");
// ClientboundBlockUpdatePacket clientboundBlockUpdatePacket = new ClientboundBlockUpdatePacket(blockPos, BlockState.);
}
use of net.minecraft.network.protocol.game.ClientboundSectionBlocksUpdatePacket in project MechanicsMain by WeaponMechanics.
the class Block_1_17_R1 method getMultiBlockMaskPacket.
private ClientboundSectionBlocksUpdatePacket getMultiBlockMaskPacket(List<Block> blocks, @Nullable BlockState mask) {
BlockPos position = ((CraftBlock) blocks.get(0)).getPosition();
// Setup default information
short[] locations = new short[blocks.size()];
BlockState[] data = new BlockState[blocks.size()];
for (int i = 0; i < locations.length; i++) {
Block block = blocks.get(i);
int x = block.getX() & 0xF;
int y = block.getY() & 0xF;
int z = block.getZ() & 0xF;
short shortLocation = (short) (x << 8 | z << 4 | y);
locations[i] = shortLocation;
data[i] = mask;
}
ClientboundSectionBlocksUpdatePacket packet = new ClientboundSectionBlocksUpdatePacket(SectionPos.of(position), new ShortArraySet(0), null, false);
ReflectionUtil.setField(multiBlockChangeB, packet, locations);
ReflectionUtil.setField(multiBlockChangeC, packet, data);
return packet;
}
use of net.minecraft.network.protocol.game.ClientboundSectionBlocksUpdatePacket in project MechanicsMain by WeaponMechanics.
the class Block_1_18_R1 method getMultiBlockMaskPacket.
private ClientboundSectionBlocksUpdatePacket getMultiBlockMaskPacket(List<Block> blocks, @Nullable BlockState mask) {
BlockPos position = ((CraftBlock) blocks.get(0)).getPosition();
// Setup default information
short[] locations = new short[blocks.size()];
BlockState[] data = new BlockState[blocks.size()];
for (int i = 0; i < locations.length; i++) {
Block block = blocks.get(i);
int x = block.getX() & 0xF;
int y = block.getY() & 0xF;
int z = block.getZ() & 0xF;
short shortLocation = (short) (x << 8 | z << 4 | y);
locations[i] = shortLocation;
data[i] = mask;
}
ClientboundSectionBlocksUpdatePacket packet = new ClientboundSectionBlocksUpdatePacket(SectionPos.of(position), new ShortArraySet(0), null, false);
ReflectionUtil.setField(multiBlockChangeB, packet, locations);
ReflectionUtil.setField(multiBlockChangeC, packet, data);
return packet;
}
use of net.minecraft.network.protocol.game.ClientboundSectionBlocksUpdatePacket in project MechanicsMain by WeaponMechanics.
the class Block_1_18_R2 method getMultiBlockMaskPacket.
private ClientboundSectionBlocksUpdatePacket getMultiBlockMaskPacket(List<Block> blocks, @Nullable BlockState mask) {
BlockPos position = ((CraftBlock) blocks.get(0)).getPosition();
// Setup default information
short[] locations = new short[blocks.size()];
BlockState[] data = new BlockState[blocks.size()];
for (int i = 0; i < locations.length; i++) {
Block block = blocks.get(i);
int x = block.getX() & 0xF;
int y = block.getY() & 0xF;
int z = block.getZ() & 0xF;
short shortLocation = (short) (x << 8 | z << 4 | y);
locations[i] = shortLocation;
data[i] = mask;
}
ClientboundSectionBlocksUpdatePacket packet = new ClientboundSectionBlocksUpdatePacket(SectionPos.of(position), new ShortArraySet(0), null, false);
ReflectionUtil.setField(multiBlockChangeB, packet, locations);
ReflectionUtil.setField(multiBlockChangeC, packet, data);
return packet;
}
Aggregations