use of net.minecraft.server.v1_16_R2.Chunk in project MechanicsMain by WeaponMechanics.
the class Block_1_15_R1 method getMultiBlockMaskPacket.
@Override
@NotNull
public List<Object> getMultiBlockMaskPacket(@NotNull List<Block> blocks, @Nullable BlockState mask) {
if (blocks == null || blocks.isEmpty()) {
throw new IllegalArgumentException("No blocks are being changed!");
}
Map<org.bukkit.Chunk, List<Block>> sortedBlocks = new HashMap<>();
for (Block block : blocks) {
List<Block> list = sortedBlocks.computeIfAbsent(block.getChunk(), chunk -> new ArrayList<>());
list.add(block);
}
List<Object> packets = new ArrayList<>(sortedBlocks.size());
IBlockData theMask = mask == null ? null : ((CraftBlockState) mask).getHandle();
for (List<Block> entry : sortedBlocks.values()) {
packets.add(getMultiBlockMaskPacket(entry, theMask));
}
return packets;
}
use of net.minecraft.server.v1_16_R2.Chunk in project TheAPI by TheDevTec.
the class v1_16_R2 method getBlock.
@Override
public Object getBlock(Object chunk, int x, int y, int z) {
net.minecraft.server.v1_16_R2.Chunk c = (net.minecraft.server.v1_16_R2.Chunk) chunk;
ChunkSection sc = c.getSections()[y >> 4];
if (sc == null)
return Blocks.AIR.getBlockData();
return sc.getBlocks().a(x & 15, y & 15, z & 15);
}
use of net.minecraft.server.v1_16_R2.Chunk in project TheAPI by TheDevTec.
the class v1_16_R2 method updateLightAt.
@Override
public void updateLightAt(Object chunk, int x, int y, int z) {
net.minecraft.server.v1_16_R2.Chunk c = (net.minecraft.server.v1_16_R2.Chunk) chunk;
c.world.getChunkProvider().getLightEngine().a(new BlockPosition(x, y, z));
}
use of net.minecraft.server.v1_16_R2.Chunk in project Movecraft by APDevTeam.
the class IWorldHandler method setBlockFast.
private void setBlockFast(@NotNull World world, @NotNull BlockPosition position, @NotNull IBlockData data) {
Chunk chunk = world.getChunkAtWorldCoords(position);
ChunkSection chunkSection = chunk.getSections()[position.getY() >> 4];
if (chunkSection == null) {
// Put a GLASS block to initialize the section. It will be replaced next with the real block.
chunk.setType(position, Blocks.GLASS.getBlockData(), false);
chunkSection = chunk.getSections()[position.getY() >> 4];
}
if (chunkSection.getType(position.getX() & 15, position.getY() & 15, position.getZ() & 15).equals(data)) {
// Block is already of correct type and data, don't overwrite
return;
}
chunkSection.setType(position.getX() & 15, position.getY() & 15, position.getZ() & 15, data);
world.notify(position, data, data, 3);
var engine = chunk.e();
if (engine != null)
engine.a(position);
chunk.markDirty();
}
use of net.minecraft.server.v1_16_R2.Chunk in project Movecraft by APDevTeam.
the class IWorldHandler method setBlockFast.
private void setBlockFast(@NotNull World world, @NotNull BlockPosition position, @NotNull IBlockData data) {
Chunk chunk = world.getChunkAtWorldCoords(position);
ChunkSection chunkSection = chunk.getSections()[position.getY() >> 4];
if (chunkSection == null) {
// Put a GLASS block to initialize the section. It will be replaced next with the real block.
chunk.setType(position, Blocks.GLASS.getBlockData(), false);
chunkSection = chunk.getSections()[position.getY() >> 4];
}
if (chunkSection.getType(position.getX() & 15, position.getY() & 15, position.getZ() & 15).equals(data)) {
// Block is already of correct type and data, don't overwrite
return;
}
chunkSection.setType(position.getX() & 15, position.getY() & 15, position.getZ() & 15, data);
world.notify(position, data, data, 3);
var engine = chunk.e();
if (engine != null)
engine.a(position);
chunk.markDirty();
}
Aggregations