net.minecraft.world.chunk.IChunkGenerator Java Examples
The following examples show how to use
net.minecraft.world.chunk.IChunkGenerator.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WorldRetrogen.java From simpleretrogen with GNU General Public License v3.0 | 5 votes |
@Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) { FMLLog.fine("Passing generation for %s through to underlying generator", tag); delegate.generate(random, chunkX, chunkZ, world, chunkGenerator, chunkProvider); ChunkPos chunkCoordIntPair = new ChunkPos(chunkX, chunkZ); completeRetrogen(chunkCoordIntPair, world, tag); }
Example #2
Source File: WorldRetrogen.java From simpleretrogen with GNU General Public License v3.0 | 5 votes |
private void runRetrogen(WorldServer world, ChunkPos chunkCoords, String retroClass) { long worldSeed = world.getSeed(); Random fmlRandom = new Random(worldSeed); long xSeed = fmlRandom.nextLong() >> 2 + 1L; long zSeed = fmlRandom.nextLong() >> 2 + 1L; long chunkSeed = (xSeed * chunkCoords.chunkXPos + zSeed * chunkCoords.chunkZPos) ^ worldSeed; fmlRandom.setSeed(chunkSeed); ChunkProviderServer providerServer = world.getChunkProvider(); IChunkGenerator generator = ObfuscationReflectionHelper.getPrivateValue(ChunkProviderServer.class, providerServer, "field_186029_c", "chunkGenerator"); delegates.get(retroClass).delegate.generate(fmlRandom, chunkCoords.chunkXPos, chunkCoords.chunkZPos, world, generator, providerServer); FMLLog.fine("Retrogenerated chunk for %s", retroClass); completeRetrogen(chunkCoords, world, retroClass); }
Example #3
Source File: TestGenerator.java From simpleretrogen with GNU General Public License v3.0 | 5 votes |
@Mod.EventHandler public void preinit(FMLPreInitializationEvent init) { final Logger modLog = init.getModLog(); IWorldGenerator gen = new IWorldGenerator() { @Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) { modLog.log(Level.INFO, "Calling!"); } }; GameRegistry.registerWorldGenerator(gen, 10); }
Example #4
Source File: WorldGenTFC.java From TFC2 with GNU General Public License v3.0 | 5 votes |
@Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGen,IChunkProvider chunkProvider) { chunk = world.getChunkFromChunkCoords(chunkX, chunkZ); chunkX *= 16; chunkZ *= 16; map = Core.getMapForWorld(world, new BlockPos(chunkX, 0, chunkZ)); iMoisture = map.getParams().getIslandMoisture(); }
Example #5
Source File: LPWorldGen.java From Logistics-Pipes-2 with MIT License | 4 votes |
@Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) { this.generateOres(random, chunkX, chunkZ, world, true); }
Example #6
Source File: ForgeQueue_All.java From FastAsyncWorldedit with GNU General Public License v3.0 | 4 votes |
@Override public boolean regenerateChunk(World world, int x, int z, BaseBiome biome, Long seed) { IChunkProvider provider = world.getChunkProvider(); if (!(provider instanceof ChunkProviderServer)) { return false; } try { ChunkProviderServer chunkServer = (ChunkProviderServer) provider; IChunkGenerator gen = chunkServer.chunkGenerator; long pos = ChunkPos.chunkXZ2Int(x, z); Chunk mcChunk; if (chunkServer.chunkExists(x, z)) { mcChunk = chunkServer.loadChunk(x, z); mcChunk.onChunkUnload(); } PlayerChunkMap playerManager = ((WorldServer) getWorld()).getPlayerChunkMap(); List<EntityPlayerMP> oldWatchers = null; if (chunkServer.chunkExists(x, z)) { mcChunk = chunkServer.loadChunk(x, z); PlayerChunkMapEntry entry = playerManager.getEntry(x, z); if (entry != null) { Field fieldPlayers = PlayerChunkMapEntry.class.getDeclaredField("field_187283_c"); fieldPlayers.setAccessible(true); oldWatchers = (List<EntityPlayerMP>) fieldPlayers.get(entry); playerManager.removeEntry(entry); } mcChunk.onChunkUnload(); } try { Field droppedChunksSetField = chunkServer.getClass().getDeclaredField("field_73248_b"); droppedChunksSetField.setAccessible(true); Set droppedChunksSet = (Set) droppedChunksSetField.get(chunkServer); droppedChunksSet.remove(pos); } catch (Throwable e) { MainUtil.handleError(e); } chunkServer.id2ChunkMap.remove(pos); mcChunk = gen.provideChunk(x, z); chunkServer.id2ChunkMap.put(pos, mcChunk); if (mcChunk != null) { mcChunk.onChunkLoad(); mcChunk.populateChunk(chunkServer, chunkServer.chunkGenerator); } if (oldWatchers != null) { for (EntityPlayerMP player : oldWatchers) { playerManager.addPlayer(player); } } return true; } catch (Throwable t) { MainUtil.handleError(t); return false; } }
Example #7
Source File: SpongeQueue_1_11.java From FastAsyncWorldedit with GNU General Public License v3.0 | 4 votes |
public boolean regenerateChunk(net.minecraft.world.World world, int x, int z) { IChunkProvider provider = world.getChunkProvider(); if (!(provider instanceof ChunkProviderServer)) { return false; } BlockFalling.fallInstantly = true; try { ChunkProviderServer chunkServer = (ChunkProviderServer) provider; IChunkGenerator gen = (IChunkGenerator) fieldChunkGenerator.get(chunkServer); long pos = ChunkPos.asLong(x, z); Chunk mcChunk; if (chunkServer.chunkExists(x, z)) { mcChunk = chunkServer.loadChunk(x, z); mcChunk.onChunkUnload(); } PlayerChunkMap playerManager = ((WorldServer) getWorld()).getPlayerChunkMap(); List<EntityPlayerMP> oldWatchers = null; if (chunkServer.chunkExists(x, z)) { mcChunk = chunkServer.loadChunk(x, z); PlayerChunkMapEntry entry = playerManager.getEntry(x, z); if (entry != null) { Field fieldPlayers = PlayerChunkMapEntry.class.getDeclaredField("field_187283_c"); fieldPlayers.setAccessible(true); oldWatchers = (List<EntityPlayerMP>) fieldPlayers.get(entry); playerManager.removeEntry(entry); } mcChunk.onChunkUnload(); } try { Field droppedChunksSetField = chunkServer.getClass().getDeclaredField("field_73248_b"); droppedChunksSetField.setAccessible(true); Set droppedChunksSet = (Set) droppedChunksSetField.get(chunkServer); droppedChunksSet.remove(pos); } catch (Throwable e) { MainUtil.handleError(e); } Long2ObjectMap<Chunk> id2ChunkMap = (Long2ObjectMap<Chunk>) fieldId2ChunkMap.get(chunkServer); id2ChunkMap.remove(pos); mcChunk = gen.provideChunk(x, z); id2ChunkMap.put(pos, mcChunk); if (mcChunk != null) { mcChunk.onChunkLoad(); mcChunk.populateChunk(chunkServer, gen); } if (oldWatchers != null) { for (EntityPlayerMP player : oldWatchers) { playerManager.addPlayer(player); } } return true; } catch (Throwable t) { MainUtil.handleError(t); return false; } finally { BlockFalling.fallInstantly = false; } }
Example #8
Source File: SpongeQueue_1_11.java From FastAsyncWorldedit with GNU General Public License v3.0 | 4 votes |
@Override public boolean regenerateChunk(net.minecraft.world.World world, int x, int z, BaseBiome biome, Long seed) { if (biome != null) { try { if (seed == null) { seed = world.getSeed(); } nmsWorld.getWorldInfo().getSeed(); boolean result; ChunkProviderOverworld generator = new ChunkProviderOverworld(nmsWorld, seed, false, ""); net.minecraft.world.biome.Biome base = net.minecraft.world.biome.Biome.getBiome(biome.getId()); net.minecraft.world.biome.Biome[] existingBiomes = new net.minecraft.world.biome.Biome[256]; Arrays.fill(existingBiomes, base); fieldBiomes.set(generator, existingBiomes); boolean cold = base.getTemperature() <= 1; IChunkGenerator existingGenerator = (IChunkGenerator) fieldChunkGenerator.get(nmsWorld.getChunkProvider()); long existingSeed = world.getSeed(); { if (genLayer == null) genLayer = new MutableGenLayer(seed); genLayer.set(biome.getId()); Object existingGenLayer1 = fieldGenLayer1.get(nmsWorld.provider.getBiomeProvider()); Object existingGenLayer2 = fieldGenLayer2.get(nmsWorld.provider.getBiomeProvider()); fieldGenLayer1.set(nmsWorld.provider.getBiomeProvider(), genLayer); fieldGenLayer2.set(nmsWorld.provider.getBiomeProvider(), genLayer); fieldSeed.set(nmsWorld.getWorldInfo(), seed); ReflectionUtils.setFailsafeFieldValue(fieldBiomeCache, this.nmsWorld.provider.getBiomeProvider(), new BiomeCache(this.nmsWorld.provider.getBiomeProvider())); ReflectionUtils.setFailsafeFieldValue(fieldChunkGenerator, this.nmsWorld.getChunkProvider(), generator); result = regenerateChunk(world, x, z); ReflectionUtils.setFailsafeFieldValue(fieldChunkGenerator, this.nmsWorld.getChunkProvider(), existingGenerator); fieldSeed.set(nmsWorld.getWorldInfo(), existingSeed); fieldGenLayer1.set(nmsWorld.provider.getBiomeProvider(), existingGenLayer1); fieldGenLayer2.set(nmsWorld.provider.getBiomeProvider(), existingGenLayer2); } return result; } catch (Throwable e) { e.printStackTrace(); } } return regenerateChunk(world, x, z); }
Example #9
Source File: ForgeQueue_All.java From FastAsyncWorldedit with GNU General Public License v3.0 | 4 votes |
@Override public boolean regenerateChunk(World world, int x, int z, BaseBiome biome, Long seed) { IChunkProvider provider = world.getChunkProvider(); if (!(provider instanceof ChunkProviderServer)) { return false; } try { ChunkProviderServer chunkServer = (ChunkProviderServer) provider; IChunkGenerator gen = chunkServer.chunkGenerator; long pos = ChunkPos.chunkXZ2Int(x, z); Chunk mcChunk; if (chunkServer.chunkExists(x, z)) { mcChunk = chunkServer.loadChunk(x, z); mcChunk.onChunkUnload(); } PlayerChunkMap playerManager = ((WorldServer) getWorld()).getPlayerChunkMap(); List<EntityPlayerMP> oldWatchers = null; if (chunkServer.chunkExists(x, z)) { mcChunk = chunkServer.loadChunk(x, z); PlayerChunkMapEntry entry = playerManager.getEntry(x, z); if (entry != null) { Field fieldPlayers = PlayerChunkMapEntry.class.getDeclaredField("field_187283_c"); fieldPlayers.setAccessible(true); oldWatchers = (List<EntityPlayerMP>) fieldPlayers.get(entry); playerManager.removeEntry(entry); } mcChunk.onChunkUnload(); } try { Field droppedChunksSetField = chunkServer.getClass().getDeclaredField("field_73248_b"); droppedChunksSetField.setAccessible(true); Set droppedChunksSet = (Set) droppedChunksSetField.get(chunkServer); droppedChunksSet.remove(pos); } catch (Throwable e) { MainUtil.handleError(e); } chunkServer.id2ChunkMap.remove(pos); mcChunk = gen.provideChunk(x, z); chunkServer.id2ChunkMap.put(pos, mcChunk); if (mcChunk != null) { mcChunk.onChunkLoad(); mcChunk.populateChunk(chunkServer, chunkServer.chunkGenerator); } if (oldWatchers != null) { for (EntityPlayerMP player : oldWatchers) { playerManager.addPlayer(player); } } return true; } catch (Throwable t) { MainUtil.handleError(t); return false; } }
Example #10
Source File: ForgeQueue_All.java From FastAsyncWorldedit with GNU General Public License v3.0 | 4 votes |
@Override public boolean regenerateChunk(net.minecraft.world.World world, int x, int z, BaseBiome biome, Long seed) { if (biome != null) { try { if (seed == null) { seed = world.getSeed(); } nmsWorld.getWorldInfo().getSeed(); boolean result; ChunkProviderOverworld generator = new ChunkProviderOverworld(nmsWorld, seed, false, ""); net.minecraft.world.biome.Biome base = net.minecraft.world.biome.Biome.getBiome(biome.getId()); fieldBiomes.set(generator, new net.minecraft.world.biome.Biome[]{base}); boolean cold = base.getTemperature() <= 1; IChunkGenerator existingGenerator = nmsWorld.getChunkProvider().chunkGenerator; long existingSeed = world.getSeed(); { if (genLayer == null) genLayer = new MutableGenLayer(seed); genLayer.set(biome.getId()); Object existingGenLayer1 = fieldGenLayer1.get(nmsWorld.provider.getBiomeProvider()); Object existingGenLayer2 = fieldGenLayer2.get(nmsWorld.provider.getBiomeProvider()); fieldGenLayer1.set(nmsWorld.provider.getBiomeProvider(), genLayer); fieldGenLayer2.set(nmsWorld.provider.getBiomeProvider(), genLayer); fieldSeed.set(nmsWorld.getWorldInfo(), seed); ReflectionUtils.setFailsafeFieldValue(fieldBiomeCache, this.nmsWorld.provider.getBiomeProvider(), new BiomeCache(this.nmsWorld.provider.getBiomeProvider())); ReflectionUtils.setFailsafeFieldValue(fieldChunkGenerator, this.nmsWorld.getChunkProvider(), generator); result = regenerateChunk(world, x, z); ReflectionUtils.setFailsafeFieldValue(fieldChunkGenerator, this.nmsWorld.getChunkProvider(), existingGenerator); fieldSeed.set(nmsWorld.getWorldInfo(), existingSeed); fieldGenLayer1.set(nmsWorld.provider.getBiomeProvider(), existingGenLayer1); fieldGenLayer2.set(nmsWorld.provider.getBiomeProvider(), existingGenLayer2); } return result; } catch (Throwable e) { e.printStackTrace(); } } return regenerateChunk(world, x, z); }
Example #11
Source File: ForgeQueue_All.java From FastAsyncWorldedit with GNU General Public License v3.0 | 4 votes |
public boolean regenerateChunk(World world, int x, int z) { IChunkProvider provider = world.getChunkProvider(); if (!(provider instanceof ChunkProviderServer)) { return false; } BlockFalling.fallInstantly = true; try { ChunkProviderServer chunkServer = (ChunkProviderServer) provider; IChunkGenerator gen = chunkServer.chunkGenerator; long pos = ChunkPos.asLong(x, z); Chunk mcChunk; if (chunkServer.chunkExists(x, z)) { mcChunk = chunkServer.loadChunk(x, z); mcChunk.onChunkUnload(); } PlayerChunkMap playerManager = ((WorldServer) getWorld()).getPlayerChunkMap(); List<EntityPlayerMP> oldWatchers = null; if (chunkServer.chunkExists(x, z)) { mcChunk = chunkServer.loadChunk(x, z); PlayerChunkMapEntry entry = playerManager.getEntry(x, z); if (entry != null) { Field fieldPlayers = PlayerChunkMapEntry.class.getDeclaredField("field_187283_c"); fieldPlayers.setAccessible(true); oldWatchers = (List<EntityPlayerMP>) fieldPlayers.get(entry); playerManager.removeEntry(entry); } mcChunk.onChunkUnload(); } try { Field droppedChunksSetField = chunkServer.getClass().getDeclaredField("field_73248_b"); droppedChunksSetField.setAccessible(true); Set droppedChunksSet = (Set) droppedChunksSetField.get(chunkServer); droppedChunksSet.remove(pos); } catch (Throwable e) { MainUtil.handleError(e); } chunkServer.id2ChunkMap.remove(pos); mcChunk = gen.provideChunk(x, z); chunkServer.id2ChunkMap.put(pos, mcChunk); if (mcChunk != null) { mcChunk.onChunkLoad(); mcChunk.populateChunk(chunkServer, chunkServer.chunkGenerator); } if (oldWatchers != null) { for (EntityPlayerMP player : oldWatchers) { playerManager.addPlayer(player); } } return true; } catch (Throwable t) { MainUtil.handleError(t); return false; } finally { BlockFalling.fallInstantly = false; } }
Example #12
Source File: WorldProviderPaths.java From TFC2 with GNU General Public License v3.0 | 4 votes |
@Override public IChunkGenerator createChunkGenerator() { return new ChunkProviderPaths(world, world.getSeed(), false, ""); }
Example #13
Source File: WorldProviderSurface.java From TFC2 with GNU General Public License v3.0 | 4 votes |
@Override public IChunkGenerator createChunkGenerator() { return new ChunkProviderSurface(this.world, world.getSeed(), false, ""); }
Example #14
Source File: PLWorldGen.java From Production-Line with MIT License | 3 votes |
/** * Generate some world * * @param random the chunk specific {@link Random}. * @param chunkX the chunk X coordinate of this chunk. * @param chunkZ the chunk Z coordinate of this chunk. * @param world : additionalData[0] The minecraft {@link World} we're generating for. * @param chunkGenerator : additionalData[1] The {@link IChunkProvider} that is generating. * @param chunkProvider : additionalData[2] {@link IChunkProvider} that is requesting the world * generation. */ @Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) { //doesWaterVaporize() return isHellWorld if ((!world.provider.doesWaterVaporize()) && (!world.provider.hasNoSky())) { generateOre(world, random, chunkX, chunkZ); } }