Search in sources :

Example 36 with ChunkSection

use of net.minecraft.server.v1_16_R1.ChunkSection 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();
}
Also used : Chunk(net.minecraft.server.v1_16_R3.Chunk) ChunkSection(net.minecraft.server.v1_16_R3.ChunkSection)

Example 37 with ChunkSection

use of net.minecraft.server.v1_16_R1.ChunkSection 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();
}
Also used : Chunk(net.minecraft.server.v1_14_R1.Chunk) ChunkSection(net.minecraft.server.v1_14_R1.ChunkSection)

Aggregations

Chunk (org.bukkit.Chunk)31 ChunkSection (net.minecraft.server.v1_7_R4.ChunkSection)5 Field (java.lang.reflect.Field)4 ChunkSection (net.minecraft.server.v1_14_R1.ChunkSection)3 ChunkSection (net.minecraft.server.v1_16_R3.ChunkSection)3 ChunkSection (net.minecraft.server.v1_10_R1.ChunkSection)2 ChunkSection (net.minecraft.server.v1_11_R1.ChunkSection)2 ChunkSection (net.minecraft.server.v1_12_R1.ChunkSection)2 ChunkSection (net.minecraft.server.v1_13_R1.ChunkSection)2 ChunkSection (net.minecraft.server.v1_13_R2.ChunkSection)2 ChunkSection (net.minecraft.server.v1_15_R1.ChunkSection)2 ChunkSection (net.minecraft.server.v1_16_R1.ChunkSection)2 ChunkSection (net.minecraft.server.v1_16_R2.ChunkSection)2 ChunkSection (net.minecraft.server.v1_7_R3.ChunkSection)2 ChunkSection (net.minecraft.server.v1_8_R1.ChunkSection)2 CraftChunk (org.bukkit.craftbukkit.v1_11_R1.CraftChunk)2 CraftChunk (org.bukkit.craftbukkit.v1_12_R1.CraftChunk)2 CraftChunk (org.bukkit.craftbukkit.v1_16_R1.CraftChunk)2 CraftChunk (org.bukkit.craftbukkit.v1_7_R4.CraftChunk)2 CraftWorld (org.bukkit.craftbukkit.v1_7_R4.CraftWorld)2