Search in sources :

Example 1 with ChunkProviderServer

use of net.minecraft.server.v1_8_R2.ChunkProviderServer in project TheAPI by TheDevTec.

the class v1_10_R1 method getChunk.

@Override
public Object getChunk(World world, int x, int z) {
    WorldServer sworld = ((CraftWorld) world).getHandle();
    net.minecraft.server.v1_10_R1.Chunk loaded = ((ChunkProviderServer) sworld.getChunkProvider()).getChunkIfLoaded(x, z);
    if (loaded == null) {
        // load
        try {
            net.minecraft.server.v1_10_R1.Chunk chunk;
            chunk = ((IChunkLoader) Ref.get(((ChunkProviderServer) sworld.getChunkProvider()), chunkLoader)).a(sworld, x, z);
            if (chunk != null) {
                chunk.setLastSaved(sworld.getTime());
                if (((ChunkProviderServer) sworld.getChunkProvider()).chunkGenerator != null) {
                    ((ChunkProviderServer) sworld.getChunkProvider()).chunkGenerator.recreateStructures(chunk, x, z);
                }
            }
            if (chunk != null) {
                ((ChunkProviderServer) sworld.getChunkProvider()).chunks.put(ChunkCoordIntPair.a(x, z), chunk);
                postToMainThread(() -> {
                    chunk.addEntities();
                });
                loaded = chunk;
            }
        } catch (Exception e) {
        }
    }
    if (loaded == null) {
        // generate new chunk
        ChunkRegionLoader loader = null;
        if ((IChunkLoader) Ref.get(((ChunkProviderServer) sworld.getChunkProvider()), chunkLoader) instanceof ChunkRegionLoader) {
            loader = (ChunkRegionLoader) Ref.get(((ChunkProviderServer) sworld.getChunkProvider()), chunkLoader);
        }
        if (loader != null && loader.chunkExists(sworld, x, z)) {
            loaded = ChunkIOExecutor.syncChunkLoad(sworld, loader, (ChunkProviderServer) sworld.getChunkProvider(), x, z);
        } else {
            loaded = ((ChunkProviderServer) sworld.getChunkProvider()).originalGetChunkAt(x, z);
        }
        loaded = ((ChunkProviderServer) sworld.getChunkProvider()).chunkGenerator.getOrCreateChunk(x, z);
        ((ChunkProviderServer) sworld.getChunkProvider()).chunks.put(ChunkCoordIntPair.a(x, z), loaded);
    }
    return loaded;
}
Also used : ChunkProviderServer(net.minecraft.server.v1_10_R1.ChunkProviderServer) WorldServer(net.minecraft.server.v1_10_R1.WorldServer) ChunkRegionLoader(net.minecraft.server.v1_10_R1.ChunkRegionLoader) CraftWorld(org.bukkit.craftbukkit.v1_10_R1.CraftWorld)

Example 2 with ChunkProviderServer

use of net.minecraft.server.v1_8_R2.ChunkProviderServer in project TheAPI by TheDevTec.

the class v1_11_R1 method getChunk.

@Override
public Object getChunk(World world, int x, int z) {
    WorldServer sworld = ((CraftWorld) world).getHandle();
    net.minecraft.server.v1_11_R1.Chunk loaded = ((ChunkProviderServer) sworld.getChunkProvider()).getChunkIfLoaded(x, z);
    if (loaded == null) {
        // load
        try {
            net.minecraft.server.v1_11_R1.Chunk chunk;
            chunk = ((IChunkLoader) Ref.get(((ChunkProviderServer) sworld.getChunkProvider()), chunkLoader)).a(sworld, x, z);
            if (chunk != null) {
                chunk.setLastSaved(sworld.getTime());
                if (((ChunkProviderServer) sworld.getChunkProvider()).chunkGenerator != null) {
                    ((ChunkProviderServer) sworld.getChunkProvider()).chunkGenerator.recreateStructures(chunk, x, z);
                }
            }
            if (chunk != null) {
                ((ChunkProviderServer) sworld.getChunkProvider()).chunks.put(ChunkCoordIntPair.a(x, z), chunk);
                postToMainThread(() -> {
                    chunk.addEntities();
                });
                loaded = chunk;
            }
        } catch (Exception e) {
        }
    }
    if (loaded == null) {
        // generate new chunk
        ChunkRegionLoader loader = null;
        if ((IChunkLoader) Ref.get(((ChunkProviderServer) sworld.getChunkProvider()), chunkLoader) instanceof ChunkRegionLoader) {
            loader = (ChunkRegionLoader) Ref.get(((ChunkProviderServer) sworld.getChunkProvider()), chunkLoader);
        }
        if (loader != null && loader.chunkExists(sworld, x, z)) {
            loaded = ChunkIOExecutor.syncChunkLoad(sworld, loader, (ChunkProviderServer) sworld.getChunkProvider(), x, z);
        } else {
            loaded = ((ChunkProviderServer) sworld.getChunkProvider()).originalGetChunkAt(x, z);
        }
        loaded = ((ChunkProviderServer) sworld.getChunkProvider()).chunkGenerator.getOrCreateChunk(x, z);
        ((ChunkProviderServer) sworld.getChunkProvider()).chunks.put(ChunkCoordIntPair.a(x, z), loaded);
    }
    return loaded;
}
Also used : ChunkProviderServer(net.minecraft.server.v1_11_R1.ChunkProviderServer) WorldServer(net.minecraft.server.v1_11_R1.WorldServer) ChunkRegionLoader(net.minecraft.server.v1_11_R1.ChunkRegionLoader) CraftWorld(org.bukkit.craftbukkit.v1_11_R1.CraftWorld)

Example 3 with ChunkProviderServer

use of net.minecraft.server.v1_8_R2.ChunkProviderServer in project TheAPI by TheDevTec.

the class v1_7_R4 method getChunk.

@Override
public Object getChunk(World world, int x, int z) {
    WorldServer sworld = ((CraftWorld) world).getHandle();
    net.minecraft.server.v1_7_R4.Chunk loaded = ((ChunkProviderServer) sworld.L()).getChunkIfLoaded(x, z);
    if (loaded == null) {
        // load
        try {
            net.minecraft.server.v1_7_R4.Chunk chunk;
            chunk = ((IChunkLoader) Ref.get(((ChunkProviderServer) sworld.L()), chunkLoader)).a(sworld, x, z);
            if (chunk != null) {
                chunk.lastSaved = sworld.getTime();
                if (((ChunkProviderServer) sworld.L()).chunkProvider != null) {
                    ((ChunkProviderServer) sworld.L()).chunkProvider.recreateStructures(x, z);
                }
            }
            if (chunk != null) {
                ((ChunkProviderServer) sworld.L()).chunks.put(ChunkCoordIntPair.a(x, z), chunk);
                postToMainThread(() -> {
                    chunk.addEntities();
                });
                loaded = chunk;
            }
        } catch (Exception e) {
        }
    }
    if (loaded == null) {
        // generate new chunk
        ChunkRegionLoader loader = null;
        if ((IChunkLoader) Ref.get(((ChunkProviderServer) sworld.L()), chunkLoader) instanceof ChunkRegionLoader) {
            loader = (ChunkRegionLoader) Ref.get(((ChunkProviderServer) sworld.L()), chunkLoader);
        }
        if (loader != null && loader.chunkExists(sworld, x, z)) {
            loaded = ChunkIOExecutor.syncChunkLoad(sworld, loader, (ChunkProviderServer) sworld.L(), x, z);
        } else {
            loaded = ((ChunkProviderServer) sworld.L()).originalGetChunkAt(x, z);
        }
        loaded = ((ChunkProviderServer) sworld.L()).chunkProvider.getOrCreateChunk(x, z);
        ((ChunkProviderServer) sworld.L()).chunks.put(ChunkCoordIntPair.a(x, z), loaded);
    }
    return loaded;
}
Also used : ChunkProviderServer(net.minecraft.server.v1_7_R4.ChunkProviderServer) WorldServer(net.minecraft.server.v1_7_R4.WorldServer) ChunkRegionLoader(net.minecraft.server.v1_7_R4.ChunkRegionLoader) CraftWorld(org.bukkit.craftbukkit.v1_7_R4.CraftWorld)

Example 4 with ChunkProviderServer

use of net.minecraft.server.v1_8_R2.ChunkProviderServer in project TheAPI by TheDevTec.

the class v1_8_R1 method getChunk.

@Override
public Object getChunk(World world, int x, int z) {
    WorldServer sworld = ((CraftWorld) world).getHandle();
    net.minecraft.server.v1_8_R1.Chunk loaded = ((ChunkProviderServer) sworld.N()).getChunkIfLoaded(x, z);
    if (loaded == null) {
        // load
        try {
            net.minecraft.server.v1_8_R1.Chunk chunk;
            chunk = ((IChunkLoader) Ref.get(((ChunkProviderServer) sworld.N()), chunkLoader)).a(sworld, x, z);
            if (chunk != null) {
                chunk.setLastSaved(sworld.getTime());
                if (((ChunkProviderServer) sworld.N()).chunkProvider != null) {
                    ((ChunkProviderServer) sworld.N()).chunkProvider.recreateStructures(chunk, x, z);
                }
            }
            if (chunk != null) {
                ((ChunkProviderServer) sworld.N()).chunks.put(ChunkCoordIntPair.a(x, z), chunk);
                postToMainThread(() -> {
                    chunk.addEntities();
                });
                loaded = chunk;
            }
        } catch (Exception e) {
        }
    }
    if (loaded == null) {
        // generate new chunk
        ChunkRegionLoader loader = null;
        if ((IChunkLoader) Ref.get(((ChunkProviderServer) sworld.N()), chunkLoader) instanceof ChunkRegionLoader) {
            loader = (ChunkRegionLoader) Ref.get(((ChunkProviderServer) sworld.N()), chunkLoader);
        }
        if (loader != null && loader.chunkExists(sworld, x, z)) {
            loaded = ChunkIOExecutor.syncChunkLoad(sworld, loader, (ChunkProviderServer) sworld.N(), x, z);
        } else {
            loaded = ((ChunkProviderServer) sworld.N()).originalGetChunkAt(x, z);
        }
        loaded = ((ChunkProviderServer) sworld.N()).chunkProvider.getOrCreateChunk(x, z);
        ((ChunkProviderServer) sworld.N()).chunks.put(ChunkCoordIntPair.a(x, z), loaded);
    }
    return loaded;
}
Also used : ChunkProviderServer(net.minecraft.server.v1_8_R1.ChunkProviderServer) WorldServer(net.minecraft.server.v1_8_R1.WorldServer) ChunkRegionLoader(net.minecraft.server.v1_8_R1.ChunkRegionLoader) CraftWorld(org.bukkit.craftbukkit.v1_8_R1.CraftWorld)

Example 5 with ChunkProviderServer

use of net.minecraft.server.v1_8_R2.ChunkProviderServer in project TheAPI by TheDevTec.

the class v1_8_R3 method getChunk.

@Override
public Object getChunk(World world, int x, int z) {
    WorldServer sworld = ((CraftWorld) world).getHandle();
    net.minecraft.server.v1_8_R3.Chunk loaded = ((ChunkProviderServer) sworld.N()).getChunkIfLoaded(x, z);
    if (loaded == null) {
        // load
        try {
            net.minecraft.server.v1_8_R3.Chunk chunk;
            chunk = ((IChunkLoader) Ref.get(((ChunkProviderServer) sworld.N()), chunkLoader)).a(sworld, x, z);
            if (chunk != null) {
                chunk.setLastSaved(sworld.getTime());
                if (((ChunkProviderServer) sworld.N()).chunkProvider != null) {
                    ((ChunkProviderServer) sworld.N()).chunkProvider.recreateStructures(chunk, x, z);
                }
            }
            if (chunk != null) {
                ((ChunkProviderServer) sworld.N()).chunks.put(ChunkCoordIntPair.a(x, z), chunk);
                postToMainThread(() -> {
                    chunk.addEntities();
                });
                loaded = chunk;
            }
        } catch (Exception e) {
        }
    }
    if (loaded == null) {
        // generate new chunk
        ChunkRegionLoader loader = null;
        if ((IChunkLoader) Ref.get(((ChunkProviderServer) sworld.N()), chunkLoader) instanceof ChunkRegionLoader) {
            loader = (ChunkRegionLoader) Ref.get(((ChunkProviderServer) sworld.N()), chunkLoader);
        }
        if (loader != null && loader.chunkExists(sworld, x, z)) {
            loaded = ChunkIOExecutor.syncChunkLoad(sworld, loader, (ChunkProviderServer) sworld.N(), x, z);
        } else {
            loaded = ((ChunkProviderServer) sworld.N()).originalGetChunkAt(x, z);
        }
        loaded = ((ChunkProviderServer) sworld.N()).chunkProvider.getOrCreateChunk(x, z);
        ((ChunkProviderServer) sworld.N()).chunks.put(ChunkCoordIntPair.a(x, z), loaded);
    }
    return loaded;
}
Also used : ChunkProviderServer(net.minecraft.server.v1_8_R3.ChunkProviderServer) WorldServer(net.minecraft.server.v1_8_R3.WorldServer) ChunkRegionLoader(net.minecraft.server.v1_8_R3.ChunkRegionLoader) CraftWorld(org.bukkit.craftbukkit.v1_8_R3.CraftWorld)

Aggregations

ChunkProviderServer (net.minecraft.server.v1_10_R1.ChunkProviderServer)1 ChunkRegionLoader (net.minecraft.server.v1_10_R1.ChunkRegionLoader)1 WorldServer (net.minecraft.server.v1_10_R1.WorldServer)1 ChunkProviderServer (net.minecraft.server.v1_11_R1.ChunkProviderServer)1 ChunkRegionLoader (net.minecraft.server.v1_11_R1.ChunkRegionLoader)1 WorldServer (net.minecraft.server.v1_11_R1.WorldServer)1 ChunkProviderServer (net.minecraft.server.v1_12_R1.ChunkProviderServer)1 ChunkRegionLoader (net.minecraft.server.v1_12_R1.ChunkRegionLoader)1 WorldServer (net.minecraft.server.v1_12_R1.WorldServer)1 ChunkProviderServer (net.minecraft.server.v1_7_R4.ChunkProviderServer)1 ChunkRegionLoader (net.minecraft.server.v1_7_R4.ChunkRegionLoader)1 WorldServer (net.minecraft.server.v1_7_R4.WorldServer)1 ChunkProviderServer (net.minecraft.server.v1_8_R1.ChunkProviderServer)1 ChunkRegionLoader (net.minecraft.server.v1_8_R1.ChunkRegionLoader)1 WorldServer (net.minecraft.server.v1_8_R1.WorldServer)1 ChunkProviderServer (net.minecraft.server.v1_8_R2.ChunkProviderServer)1 ChunkRegionLoader (net.minecraft.server.v1_8_R2.ChunkRegionLoader)1 WorldServer (net.minecraft.server.v1_8_R2.WorldServer)1 ChunkProviderServer (net.minecraft.server.v1_8_R3.ChunkProviderServer)1 ChunkRegionLoader (net.minecraft.server.v1_8_R3.ChunkRegionLoader)1