Search in sources :

Example 16 with Chunk

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

the class v1_7_R4 method getData.

@Override
public int getData(Object chunk, int x, int y, int z) {
    net.minecraft.server.v1_7_R4.Chunk c = (net.minecraft.server.v1_7_R4.Chunk) chunk;
    ChunkSection sc = c.getSections()[y >> 4];
    if (sc == null)
        return 0;
    return sc.getData(x & 15, y & 15, z & 15);
}
Also used : Chunk(org.bukkit.Chunk) CraftChunk(org.bukkit.craftbukkit.v1_7_R4.CraftChunk) ChunkSection(net.minecraft.server.v1_7_R4.ChunkSection)

Example 17 with Chunk

use of net.minecraft.server.v1_7_R4.Chunk in project acidisland by tastybento.

the class NMSHandler method setBlockSuperFast.

@SuppressWarnings("deprecation")
@Override
public void setBlockSuperFast(Block b, int blockId, byte data, boolean applyPhysics) {
    net.minecraft.server.v1_7_R4.World w = ((CraftWorld) b.getWorld()).getHandle();
    net.minecraft.server.v1_7_R4.Chunk chunk = w.getChunkAt(b.getX() >> 4, b.getZ() >> 4);
    try {
        Field f = chunk.getClass().getDeclaredField("sections");
        f.setAccessible(true);
        ChunkSection[] sections = (ChunkSection[]) f.get(chunk);
        ChunkSection chunksection = sections[b.getY() >> 4];
        if (chunksection == null) {
            chunksection = sections[b.getY() >> 4] = new ChunkSection(b.getY() >> 4 << 4, !chunk.world.worldProvider.f);
        }
        net.minecraft.server.v1_7_R4.Block mb = net.minecraft.server.v1_7_R4.Block.getById(blockId);
        chunksection.setTypeId(b.getX() & 15, b.getY() & 15, b.getZ() & 15, mb);
        chunksection.setData(b.getX() & 15, b.getY() & 15, b.getZ() & 15, data);
        if (applyPhysics) {
            w.update(b.getX(), b.getY(), b.getZ(), mb);
        }
    } catch (Exception e) {
        // Bukkit.getLogger().info("Error");
        b.setTypeIdAndData(blockId, data, applyPhysics);
    }
}
Also used : Field(java.lang.reflect.Field) CraftWorld(org.bukkit.craftbukkit.v1_7_R4.CraftWorld) ChunkSection(net.minecraft.server.v1_7_R4.ChunkSection)

Example 18 with Chunk

use of net.minecraft.server.v1_7_R4.Chunk in project askyblock by tastybento.

the class NMSHandler method setBlockSuperFast.

@SuppressWarnings("deprecation")
@Override
public void setBlockSuperFast(Block b, int blockId, byte data, boolean applyPhysics) {
    net.minecraft.server.v1_7_R4.World w = ((CraftWorld) b.getWorld()).getHandle();
    net.minecraft.server.v1_7_R4.Chunk chunk = w.getChunkAt(b.getX() >> 4, b.getZ() >> 4);
    try {
        Field f = chunk.getClass().getDeclaredField("sections");
        f.setAccessible(true);
        ChunkSection[] sections = (ChunkSection[]) f.get(chunk);
        ChunkSection chunksection = sections[b.getY() >> 4];
        if (chunksection == null) {
            chunksection = sections[b.getY() >> 4] = new ChunkSection(b.getY() >> 4 << 4, !chunk.world.worldProvider.f);
        }
        net.minecraft.server.v1_7_R4.Block mb = net.minecraft.server.v1_7_R4.Block.getById(blockId);
        chunksection.setTypeId(b.getX() & 15, b.getY() & 15, b.getZ() & 15, mb);
        chunksection.setData(b.getX() & 15, b.getY() & 15, b.getZ() & 15, data);
        if (applyPhysics) {
            w.update(b.getX(), b.getY(), b.getZ(), mb);
        }
    } catch (Exception e) {
        // Bukkit.getLogger().info("Error");
        b.setTypeIdAndData(blockId, data, applyPhysics);
    }
}
Also used : Field(java.lang.reflect.Field) CraftWorld(org.bukkit.craftbukkit.v1_7_R4.CraftWorld) ChunkSection(net.minecraft.server.v1_7_R4.ChunkSection)

Example 19 with Chunk

use of net.minecraft.server.v1_7_R4.Chunk in project RoseStacker by Rosewood-Development.

the class NMSHandlerImpl method spawnExistingEntity.

@Override
public void spawnExistingEntity(LivingEntity entity, SpawnReason spawnReason, boolean bypassSpawnEvent) {
    Location location = entity.getLocation();
    World world = location.getWorld();
    if (world == null)
        throw new IllegalArgumentException("Entity is not in a loaded world");
    if (bypassSpawnEvent) {
        IChunkAccess ichunkaccess = ((CraftWorld) world).getHandle().getChunkAt(MathHelper.floor(entity.getLocation().getX() / 16.0D), MathHelper.floor(entity.getLocation().getZ() / 16.0D), ChunkStatus.FULL, false);
        if (!(ichunkaccess instanceof Chunk))
            return;
        ichunkaccess.a(((CraftEntity) entity).getHandle());
        ((CraftWorld) world).getHandle().addEntityChunk(((CraftEntity) entity).getHandle());
    } else {
        ((CraftWorld) world).addEntity(((CraftEntity) entity).getHandle(), spawnReason);
    }
}
Also used : IChunkAccess(net.minecraft.server.v1_16_R3.IChunkAccess) World(org.bukkit.World) CraftWorld(org.bukkit.craftbukkit.v1_16_R3.CraftWorld) Chunk(net.minecraft.server.v1_16_R3.Chunk) CraftWorld(org.bukkit.craftbukkit.v1_16_R3.CraftWorld) Location(org.bukkit.Location)

Example 20 with Chunk

use of net.minecraft.server.v1_7_R4.Chunk in project dynmap by webbukkit.

the class MapChunkCache116_3 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.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.server.v1_16_R2.NBTTagCompound) GenericChunk(org.dynmap.common.chunk.GenericChunk) DynmapChunk(org.dynmap.DynmapChunk) Chunk(net.minecraft.server.v1_16_R2.Chunk) CraftWorld(org.bukkit.craftbukkit.v1_16_R2.CraftWorld)

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 ChunkSection (net.minecraft.server.v1_7_R4.ChunkSection)4 CraftChunk (org.bukkit.craftbukkit.v1_7_R4.CraftChunk)4 CraftWorld (org.bukkit.craftbukkit.v1_7_R4.CraftWorld)4 DynmapChunk (org.dynmap.DynmapChunk)4 GenericChunk (org.dynmap.common.chunk.GenericChunk)4