Search in sources :

Example 1 with Chunk

use of net.minecraft.world.level.chunk.Chunk in project dynmap by webbukkit.

the class MapChunkCache118_2 method getLoadedChunk.

// Load generic chunk from existing and already loaded chunk
protected GenericChunk getLoadedChunk(DynmapChunk chunk) {
    CraftWorld cw = (CraftWorld) w;
    NBTTagCompound nbt = null;
    GenericChunk gc = null;
    if (cw.isChunkLoaded(chunk.x, chunk.z)) {
        Chunk c = cw.getHandle().getChunkIfLoaded(chunk.x, chunk.z);
        if ((c != null) && c.o) {
            // c.loaded
            nbt = ChunkRegionLoader.a(cw.getHandle(), c);
        }
        if (nbt != null) {
            gc = parseChunkFromNBT(new NBT.NBTCompound(nbt));
        }
    }
    return gc;
}
Also used : GenericChunk(org.dynmap.common.chunk.GenericChunk) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) GenericChunk(org.dynmap.common.chunk.GenericChunk) Chunk(net.minecraft.world.level.chunk.Chunk) DynmapChunk(org.dynmap.DynmapChunk) CraftWorld(org.bukkit.craftbukkit.v1_18_R2.CraftWorld)

Example 2 with Chunk

use of net.minecraft.world.level.chunk.Chunk in project dynmap by webbukkit.

the class MapChunkCache118 method getLoadedChunk.

// Load generic chunk from existing and already loaded chunk
protected GenericChunk getLoadedChunk(DynmapChunk chunk) {
    CraftWorld cw = (CraftWorld) w;
    NBTTagCompound nbt = null;
    GenericChunk gc = null;
    if (cw.isChunkLoaded(chunk.x, chunk.z)) {
        Chunk c = cw.getHandle().getChunkIfLoaded(chunk.x, chunk.z);
        if ((c != null) && c.o) {
            // c.loaded
            nbt = ChunkRegionLoader.a(cw.getHandle(), c);
        }
        if (nbt != null) {
            gc = parseChunkFromNBT(new NBT.NBTCompound(nbt));
        }
    }
    return gc;
}
Also used : GenericChunk(org.dynmap.common.chunk.GenericChunk) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) GenericChunk(org.dynmap.common.chunk.GenericChunk) Chunk(net.minecraft.world.level.chunk.Chunk) DynmapChunk(org.dynmap.DynmapChunk) CraftWorld(org.bukkit.craftbukkit.v1_18_R1.CraftWorld)

Example 3 with Chunk

use of net.minecraft.world.level.chunk.Chunk in project dynmap by webbukkit.

the class MapChunkCache117 method getLoadedChunk.

// Load generic chunk from existing and already loaded chunk
protected GenericChunk getLoadedChunk(DynmapChunk chunk) {
    CraftWorld cw = (CraftWorld) w;
    NBTTagCompound nbt = null;
    GenericChunk gc = null;
    if (cw.isChunkLoaded(chunk.x, chunk.z)) {
        Chunk c = cw.getHandle().getChunkAt(chunk.x, chunk.z);
        if ((c != null) && c.h) {
            // c.loaded
            nbt = ChunkRegionLoader.saveChunk(cw.getHandle(), c);
        }
        if (nbt != null) {
            gc = parseChunkFromNBT(new NBT.NBTCompound(nbt));
        }
    }
    return gc;
}
Also used : GenericChunk(org.dynmap.common.chunk.GenericChunk) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) GenericChunk(org.dynmap.common.chunk.GenericChunk) Chunk(net.minecraft.world.level.chunk.Chunk) DynmapChunk(org.dynmap.DynmapChunk) CraftWorld(org.bukkit.craftbukkit.v1_17_R1.CraftWorld)

Example 4 with Chunk

use of net.minecraft.world.level.chunk.Chunk in project WildChests by BG-Software-LLC.

the class NMSInventory_v1_17_R1 method updateTileEntity.

@Override
public void updateTileEntity(Chest chest) {
    Location loc = chest.getLocation();
    World world = ((CraftWorld) loc.getWorld()).getHandle();
    BlockPosition blockPosition = new BlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
    TileEntity tileEntity = world.getTileEntity(blockPosition);
    TileEntityWildChest tileEntityWildChest;
    if (tileEntity instanceof TileEntityWildChest) {
        tileEntityWildChest = (TileEntityWildChest) tileEntity;
        ((WChest) chest).setTileEntityContainer(tileEntityWildChest);
    } else {
        tileEntityWildChest = new TileEntityWildChest(chest, world, blockPosition);
        world.removeTileEntity(blockPosition);
        world.setTileEntity(tileEntityWildChest);
        Chunk chunk = world.getChunkAtWorldCoords(blockPosition);
        world.a(CREATE_TICKING_BLOCK.invoke(chunk, tileEntityWildChest, tileEntityWildChest));
    }
}
Also used : TileEntity(net.minecraft.world.level.block.entity.TileEntity) BlockPosition(net.minecraft.core.BlockPosition) CraftWorld(org.bukkit.craftbukkit.v1_17_R1.CraftWorld) World(net.minecraft.world.level.World) WChest(com.bgsoftware.wildchests.objects.chests.WChest) Chunk(net.minecraft.world.level.chunk.Chunk) CraftWorld(org.bukkit.craftbukkit.v1_17_R1.CraftWorld) Location(org.bukkit.Location)

Aggregations

Chunk (net.minecraft.world.level.chunk.Chunk)4 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)3 DynmapChunk (org.dynmap.DynmapChunk)3 GenericChunk (org.dynmap.common.chunk.GenericChunk)3 CraftWorld (org.bukkit.craftbukkit.v1_17_R1.CraftWorld)2 WChest (com.bgsoftware.wildchests.objects.chests.WChest)1 BlockPosition (net.minecraft.core.BlockPosition)1 World (net.minecraft.world.level.World)1 TileEntity (net.minecraft.world.level.block.entity.TileEntity)1 Location (org.bukkit.Location)1 CraftWorld (org.bukkit.craftbukkit.v1_18_R1.CraftWorld)1 CraftWorld (org.bukkit.craftbukkit.v1_18_R2.CraftWorld)1