Search in sources :

Example 31 with Chunk

use of net.minecraft.server.v1_16_R1.Chunk in project TheAPI by TheDevTec.

the class v1_16_R1 method updateLightAt.

@Override
public void updateLightAt(Object chunk, int x, int y, int z) {
    net.minecraft.server.v1_16_R1.Chunk c = (net.minecraft.server.v1_16_R1.Chunk) chunk;
    c.world.getChunkProvider().getLightEngine().a(new BlockPosition(x, y, z));
}
Also used : BlockPosition(net.minecraft.server.v1_16_R1.BlockPosition) Chunk(org.bukkit.Chunk) CraftChunk(org.bukkit.craftbukkit.v1_16_R1.CraftChunk)

Example 32 with Chunk

use of net.minecraft.server.v1_16_R1.Chunk in project TheAPI by TheDevTec.

the class v1_16_R1 method setBlock.

@Override
public void setBlock(Object chunk, int x, int y, int z, Object IblockData, int data) {
    net.minecraft.server.v1_16_R1.Chunk c = (net.minecraft.server.v1_16_R1.Chunk) chunk;
    ChunkSection sc = c.getSections()[y >> 4];
    if (sc == null) {
        c.getSections()[y >> 4] = sc = new ChunkSection(y >> 4 << 4);
    }
    BlockPosition pos = new BlockPosition(x, y, z);
    // REMOVE TILE ENTITY
    c.tileEntities.remove(pos);
    sc.getBlocks().b(x & 15, y & 15, z & 15, (IBlockData) IblockData);
    // ADD TILE ENTITY
    if (IblockData instanceof ITileEntity) {
        TileEntity ent = ((ITileEntity) IblockData).createTile(c);
        c.tileEntities.put(pos, ent);
        Object packet = ent.getUpdatePacket();
        Bukkit.getOnlinePlayers().forEach(player -> BukkitLoader.getPacketHandler().send(player, packet));
    }
}
Also used : TileEntity(net.minecraft.server.v1_16_R1.TileEntity) ITileEntity(net.minecraft.server.v1_16_R1.ITileEntity) ITileEntity(net.minecraft.server.v1_16_R1.ITileEntity) BlockPosition(net.minecraft.server.v1_16_R1.BlockPosition) Chunk(org.bukkit.Chunk) CraftChunk(org.bukkit.craftbukkit.v1_16_R1.CraftChunk) ChunkSection(net.minecraft.server.v1_16_R1.ChunkSection)

Example 33 with Chunk

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

Example 34 with Chunk

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

Example 35 with Chunk

use of net.minecraft.server.v1_16_R1.Chunk in project PaperDev by Kamillaova.

the class ChunkIOProvider method callStage1.

// async stuff
public Chunk callStage1(QueuedChunk queuedChunk) throws RuntimeException {
    try (Timing ignored = queuedChunk.provider.world.timings.chunkIOStage1.startTimingIfSync()) {
        // Paper
        ChunkRegionLoader loader = queuedChunk.loader;
        Object[] data = loader.loadChunk(queuedChunk.world, queuedChunk.x, queuedChunk.z);
        if (data != null) {
            queuedChunk.compound = (NBTTagCompound) data[1];
            return (Chunk) data[0];
        }
        return null;
    } catch (IOException ex) {
        throw new RuntimeException(ex);
    // Paper - Mirror vanilla by catching everything (else) rather than immediately crashing the server
    // stage2 will receive a null chunk and then load it synchronously, where vanilla MC will properly log and recover
    // stage2 will _not_ however return that instance, only load it
    } catch (Exception ex) {
        return null;
    }
}
Also used : Timing(co.aikar.timings.Timing) IOException(java.io.IOException) ChunkRegionLoader(net.minecraft.server.v1_12_R1.ChunkRegionLoader) Chunk(net.minecraft.server.v1_12_R1.Chunk) IOException(java.io.IOException)

Aggregations

Location (org.bukkit.Location)13 ArrayList (java.util.ArrayList)11 List (java.util.List)11 HashMap (java.util.HashMap)10 WildLoadersPlugin (com.bgsoftware.wildloaders.WildLoadersPlugin)8 Hologram (com.bgsoftware.wildloaders.api.holograms.Hologram)8 ChunkLoader (com.bgsoftware.wildloaders.api.loaders.ChunkLoader)8 ChunkLoaderNPC (com.bgsoftware.wildloaders.api.npc.ChunkLoaderNPC)8 ITileEntityChunkLoader (com.bgsoftware.wildloaders.loaders.ITileEntityChunkLoader)8 WChunkLoader (com.bgsoftware.wildloaders.loaders.WChunkLoader)8 Collection (java.util.Collection)8 Collections (java.util.Collections)8 Map (java.util.Map)8 UUID (java.util.UUID)8 Chunk (net.minecraft.server.v1_16_R3.Chunk)8 Chunk (net.minecraft.server.v1_12_R1.Chunk)6 GenericChunk (org.dynmap.common.chunk.GenericChunk)6 Chunk (net.minecraft.server.v1_15_R1.Chunk)4 DynmapChunk (org.dynmap.DynmapChunk)4 ChestType (com.bgsoftware.wildchests.api.objects.ChestType)3