@Override public void generate(Random rand, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) { int blockX = chunkX * 16; int blockZ = chunkZ * 16; switch (world.provider.getDimension()) { case -1: generateNether(world, rand, blockX + 8, blockZ + 8); break; case 0: generateOverworld(world, rand, blockX + 8, blockZ + 8); break; case 1: generateEnd(world, rand, blockX + 8, blockZ + 8); break; } }
public void generate(IChunkProvider chunkProviderIn, World worldIn, int x, int z, ChunkPrimer chunkPrimerIn) { int i = this.range; this.worldObj = worldIn; this.rand.setSeed(worldIn.getSeed()); long j = this.rand.nextLong(); long k = this.rand.nextLong(); for (int l = x - i; l <= x + i; ++l) { for (int i1 = z - i; i1 <= z + i; ++i1) { long j1 = (long)l * j; long k1 = (long)i1 * k; this.rand.setSeed(j1 ^ k1 ^ worldIn.getSeed()); this.recursiveGenerate(worldIn, l, i1, x, z, chunkPrimerIn); } } }
@Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) { switch(world.provider.getDimension()) { case -1: break; case 0: genSurface(world, random, chunkX, chunkZ, chunkGenerator, chunkProvider); break; case 1: break; } }
@Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) { if (random.nextInt(20) == 0){ int x = chunkX * 16 + 2 + random.nextInt(12); int z = chunkZ * 16 + 2 + random.nextInt(12); BlockPos p = new BlockPos(x,0,z); p = world.getHeight(p); Biome b = world.getBiome(p); if (BiomeDictionary.hasType(b, BiomeDictionary.Type.FOREST) || b == Biomes.FOREST || b == Biomes.FOREST_HILLS){ if (world.getBlockState(p.down()).getBlock() instanceof BlockGrass && world.isAirBlock(p)){ BlockTeaSapling.generateTree(world, p, Blocks.AIR.getDefaultState(), random); } } } }
@Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { switch (world.provider.dimensionId) { case 0: this.lowOre(this.generation_copper, world, random, chunkX, chunkZ, 30, 0, 256); this.lowOre(this.generation_tin, world, random, chunkX, chunkZ, 30, 0, 256); this.mediumOre(this.generation_lead, world, random, chunkX, chunkZ, 30, 0, 256); this.mediumOre(this.generation_aluminium, world, random, chunkX, chunkZ, 30, 0, 256); this.mediumOre(this.generation_nickel, world, random, chunkX, chunkZ, 30, 0, 256); this.hardOre(this.generation_ruby, world, random, chunkX, chunkZ, 30, 0, 256); this.hardOre(this.generation_uranium, world, random, chunkX, chunkZ, 30, 0, 256); break; case -1: this.netherOre(this.generation_sulfur, world, random, chunkX, chunkZ, 40, 0, 256); break; case 1: break; } }
@Override public void generate (Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) { int x = chunkX * 16 + 8; int z = chunkZ * 16 + 8; Biome biome = world.getBiome(new BlockPos(x, 0, z)); if (BiomeDictionary.hasType(biome, BiomeDictionary.Type.COLD )) if (BiomeDictionary.hasType(biome, BiomeDictionary.Type.COLD) || BiomeDictionary.hasType(biome, BiomeDictionary.Type.NETHER) || BiomeDictionary.hasType(biome, BiomeDictionary.Type.WET) || BiomeDictionary.hasType(biome, BiomeDictionary.Type.WASTELAND) || BiomeDictionary.hasType(biome, BiomeDictionary.Type.SNOWY)) return; if (!BiomeDictionary.hasType(biome, BiomeDictionary.Type.SANDY)) return; if (random.nextInt(15) > 0) return; generate(world, random, new BlockPos(x, world.getSeaLevel(), z)); }
/** * Populates chunk with ores etc etc */ public void populate(IChunkProvider p_73153_1_, int p_73153_2_, int p_73153_3_) { Chunk chunk = this.provideChunk(p_73153_2_, p_73153_3_); if (!chunk.isTerrainPopulated()) { chunk.func_150809_p(); if (this.serverChunkGenerator != null) { this.serverChunkGenerator.populate(p_73153_1_, p_73153_2_, p_73153_3_); chunk.setChunkModified(); } } }
@Override void gen(World world, int x, int z, IChunkGenerator generator, IChunkProvider provider) { random.setSeed(world.getSeed()); long good = random.nextLong(); long succ = random.nextLong(); good *= x >> 1; succ *= z >> 1; random.setSeed(good ^ succ ^ world.getSeed()); //Generate if(GEN_CONFIG.ASHEN_CUBE_STRUCTURE.rarity > 0D && GEN_CONFIG.ASHEN_CUBE_STRUCTURE.rarity / 100D > random.nextDouble()) { BlockPos center = new BlockPos(x, 15 + random.nextInt(25), z); if(!world.canSeeSky(center) || !GEN_CONFIG.ASHEN_CUBE_STRUCTURE.underground) { genCubes(world, center); } } }
public int getCountLoadedChunks() { if (this.theWorld == null) { return 0; } else { IChunkProvider ichunkprovider = this.theWorld.getChunkProvider(); if (ichunkprovider == null) { return 0; } else { if (ichunkprovider != this.worldChunkProvider) { this.worldChunkProvider = ichunkprovider; this.worldChunkProviderMap = (Long2ObjectMap)Reflector.getFieldValue(ichunkprovider, Reflector.ChunkProviderClient_chunkMapping); } return this.worldChunkProviderMap == null ? 0 : this.worldChunkProviderMap.size(); } } }
@Override public void populate(IChunkProvider par1IChunkProvider, int par2, int par3) { BlockFalling.fallInstantly = true; int var4 = par2 * 16; int var5 = par3 * 16; this.worldObj.getBiomeGenForCoords(var4 + 16, var5 + 16); this.rand.setSeed(this.worldObj.getSeed()); final long var7 = this.rand.nextLong() / 2L * 2L + 1L; final long var9 = this.rand.nextLong() / 2L * 2L + 1L; this.rand.setSeed(par2 * var7 + par3 * var9 ^ this.worldObj.getSeed()); this.decoratePlanet(this.worldObj, this.rand, var4, var5); this.onPopulate(par1IChunkProvider, par2, par3); BlockFalling.fallInstantly = false; }
@Override public void populate(IChunkProvider chunk, int x, int z) { BlockFalling.fallInstantly = true; int var4 = x * 16; int var5 = z * 16; BiomeGenBase biomeGen = this.worldObj.getBiomeGenForCoords(var4 + 16, var5 + 16); this.worldObj.getBiomeGenForCoords(var4 + 16, var5 + 16); this.rand.setSeed(this.worldObj.getSeed()); long var7 = this.rand.nextLong() / 2L * 2L + 1L; long var9 = this.rand.nextLong() / 2L * 2L + 1L; this.rand.setSeed(x * var7 + z * var9 ^ this.worldObj.getSeed()); biomeGen.decorate(this.worldObj, this.rand, var4, var5); this.decoratePlanet(this.worldObj, this.rand, var4, var5); SpawnerAnimals.performWorldGenSpawning(this.worldObj, biomeGen, var4 + 8, var5 + 8, 16, 16, this.rand); this.onPopulate(chunk, x, z); BlockFalling.fallInstantly = false; }
/** * Callback hook for world gen - if your mod wishes to add extra mod related generation to the world * call this * * @param chunkX Chunk X coordinate * @param chunkZ Chunk Z coordinate * @param world World we're generating into * @param chunkGenerator The chunk generator * @param chunkProvider The chunk provider */ public static void generateWorld(int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) { if (sortedGeneratorList == null) { computeSortedGeneratorList(); } long worldSeed = world.getSeed(); Random fmlRandom = new Random(worldSeed); long xSeed = fmlRandom.nextLong() >> 2 + 1L; long zSeed = fmlRandom.nextLong() >> 2 + 1L; long chunkSeed = (xSeed * chunkX + zSeed * chunkZ) ^ worldSeed; for (IWorldGenerator generator : sortedGeneratorList) { fmlRandom.setSeed(chunkSeed); generator.generate(fmlRandom, chunkX, chunkZ, world, chunkGenerator, chunkProvider); } }
public boolean func_177460_a(IChunkProvider p_177460_1_, Chunk p_177460_2_, int p_177460_3_, int p_177460_4_) { boolean flag = false; if (this.settings.useMonuments && this.mapFeaturesEnabled && p_177460_2_.getInhabitedTime() < 3600L) { flag |= this.oceanMonumentGenerator.generateStructure(this.worldObj, this.rand, new ChunkCoordIntPair(p_177460_3_, p_177460_4_)); } return flag; }
@Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) { //System.out.println("Generating "+bs+" at "+chunkX+", "+chunkZ); int x = random.nextInt(16); int z = random.nextInt(16); BlockPos pos = new BlockPos((chunkX*16)+x,0,(chunkZ*16)+z); pos = world.getTopSolidOrLiquidBlock(pos); //pos = pos.up(); generate(world, random, pos); }
@Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) { byte b = world.getChunkFromChunkCoords(chunkX, chunkZ).getBiomeArray()[0]; FirmaTree[] tl = FirmaBiome.getTreeForBiome(b, chunkZ*16); if(tl.length==0){ return; } FirmaTree ft = tl[random.nextInt(tl.length)]; FirmaBiome bi = (FirmaBiome) Biome.getBiome(b); for(int i = 0; i < bi.treeCount; i++){ ft.generate(random, chunkX, chunkZ, world, chunkGenerator, chunkProvider); } }
@Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) { if(stoneSpawnList.size() > 0 && world.provider.getDimension() != -1 && world.provider.getDimension() != 1) { stoneSpawnList.get(random.nextInt(stoneSpawnList.size())).generate(world, random, (chunkX * 16), (chunkZ * 16)); } }
private void generateEnd(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { if (TOConfig.generationOres && TOConfig.generationEndstoneEnable) gemerateOre((BlockInfusedBlockOre) TOBlocks.endstoneInfusedOre, world, random, chunkX, chunkZ, TOConfig.generationEndstoneVeinSize, TOConfig.generationEndstoneMaxOnChunk, TOConfig.generationEndstoneMinY, TOConfig.generationEndstoneMaxY); }
private boolean isChunkReady() { // First, find the starting position we ought to have: List<AgentSection> agents = currentMissionInit().getMission().getAgentSection(); if (agents == null || agents.size() <= currentMissionInit().getClientRole()) return true; // This should never happen. AgentSection as = agents.get(currentMissionInit().getClientRole()); if (as.getAgentStart() != null && as.getAgentStart().getPlacement() != null) { PosAndDirection pos = as.getAgentStart().getPlacement(); int x = MathHelper.floor_double(pos.getX().doubleValue()) >> 4; int z = MathHelper.floor_double(pos.getZ().doubleValue()) >> 4; // Now get the chunk we should be starting in: IChunkProvider chunkprov = Minecraft.getMinecraft().theWorld.getChunkProvider(); EntityPlayerSP player = Minecraft.getMinecraft().thePlayer; if (player.addedToChunk) { // Our player is already added to a chunk - is it the right one? Chunk actualChunk = chunkprov.provideChunk(player.chunkCoordX, player.chunkCoordZ); Chunk requestedChunk = chunkprov.provideChunk(x, z); if (actualChunk == requestedChunk && actualChunk != null && !actualChunk.isEmpty()) { // We're in the right chunk, and it's not an empty chunk. // We're ready to proceed, but first set our client positions to where we ought to be. // The server should be doing this too, but there's no harm (probably) in doing it ourselves. player.posX = pos.getX().doubleValue(); player.posY = pos.getY().doubleValue(); player.posZ = pos.getZ().doubleValue(); return true; } } return false; // Our starting position has been specified, but it's not yet ready. } return true; // No starting position specified, so doesn't matter where we start. }
public HookedClientWorld(WorldClient originalWorld) throws IllegalAccessException { super(InjectionHandler.readFieldOfType(originalWorld, NetHandlerPlayClient.class), new WorldSettings(originalWorld.getWorldInfo()), originalWorld.provider.getDimension(), originalWorld.getDifficulty(), originalWorld.profiler); HookedChunkProviderClient chunkProvider = new HookedChunkProviderClient(this); // replace the chunk provider with our own! InjectionHandler.writeFieldOfType(this, chunkProvider, ChunkProviderClient.class); InjectionHandler.writeFieldOfType(this, chunkProvider, IChunkProvider.class); SetupWorldProviderProxy(); }
/** * Creates the chunk provider for this world. Called in the constructor. Retrieves provider from worldProvider? */ protected IChunkProvider createChunkProvider() { IChunkLoader ichunkloader = this.saveHandler.getChunkLoader(this.provider); this.theChunkProviderServer = new ChunkProviderServer(this, ichunkloader, this.provider.createChunkGenerator()); return this.theChunkProviderServer; }
public boolean func_177460_a(IChunkProvider p_177460_1_, Chunk p_177460_2_, int p_177460_3_, int p_177460_4_) { if (this.serverChunkGenerator != null && this.serverChunkGenerator.func_177460_a(p_177460_1_, p_177460_2_, p_177460_3_, p_177460_4_)) { Chunk chunk = this.provideChunk(p_177460_3_, p_177460_4_); chunk.setChunkModified(); return true; } else { return false; } }
public ChunkProviderServer(WorldServer p_i1520_1_, IChunkLoader p_i1520_2_, IChunkProvider p_i1520_3_) { this.dummyChunk = new EmptyChunk(p_i1520_1_, 0, 0); this.worldObj = p_i1520_1_; this.chunkLoader = p_i1520_2_; this.serverChunkGenerator = p_i1520_3_; }
@Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) { if (world.provider.getDimension() != dimension) { return; } BlockPos chunkPos = new BlockPos(chunkX * 16, 0, chunkZ * 16); if (maxHeight < minHeight) { int i = minHeight; minHeight = maxHeight; maxHeight = i; } else if (maxHeight == minHeight) { if (minHeight < 255) { ++maxHeight; } else { --minHeight; } } for (int j = 0; j < count; ++j) { BlockPos blockpos = chunkPos.add(random.nextInt(16), random.nextInt(maxHeight - minHeight) + minHeight, random.nextInt(16)); gen.generate(world, random, blockpos); } }
private void generateNether(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { if (TOConfig.generationOres && TOConfig.generationNetherrackEnable) gemerateOre((BlockInfusedBlockOre) TOBlocks.netherrackInfusedOre, world, random, chunkX, chunkZ, TOConfig.generationNetherrackVeinSize, TOConfig.generationNetherrackMaxOnChunk, TOConfig.generationNetherrackMinY, TOConfig.generationNetherrackMaxY); }
@Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { switch (world.provider.dimensionId) { case 0: break; case -1: this.runGenerator(this.magma, world, random, chunkX, chunkZ, 100, 0, 256); break; case 1: break; } }
@Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) { switch (world.provider.getDimension()) { case -1: break; case 0: generateSurface(world, random, chunkX * 16, chunkZ * 16); break; case 1: break; } }
@Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) { if (dimList.contains(world.provider.getDimension()) == dimListMode) { if (random.nextFloat() <= chance) { int x = chunkX * 16 + 16; int z = chunkZ * 16 + 16; BlockPos pos = new BlockPos(x, world.getHeight(x, z) - 1, z); if (pos.getY() >= minY && pos.getY() <= maxY) { try { NBTTagCompound tag = StructureApi.INSTANCE.getStructureNbt(Utils.gRL("lab_medium")); PurMag.INSTANCE.debug("WG START [lab_medium]"); StructureApi.INSTANCE.spawnStructure(tag, pos, null, Rotation.values()[random.nextInt(Rotation.values().length)], (WorldServer) world, random); PurMag.INSTANCE.debug("WG END AT " + pos); } catch (IOException e) { PurMag.INSTANCE.log.error("An IOException occurred when spawning the small lab structure!", e); } } } } }
@Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) { if(dimList.contains(world.provider.getDimension()) == dimListMode) { int x = chunkX * 16 + random.nextInt(16); int z = chunkZ * 16 + random.nextInt(16); float sif = PurMag.INSTANCE.sif_storage.get(new GlobalChunkPos(chunkX, chunkZ, world.provider.getDimension())); int y = predicate.getY(random, chunkX, chunkZ, world, chunkGenerator, chunkProvider, x, z, sif); BlockPos pos = new BlockPos(x, y, z); if (predicate.canGenerateHere(random, chunkX, chunkZ, world, chunkGenerator, chunkProvider, pos, sif)) { int count = predicate.getCrystalCount(random, chunkX, chunkZ, world, chunkGenerator, chunkProvider, pos, sif); predicate.beforePlace(random, chunkX, chunkZ, world, chunkGenerator, chunkProvider, pos, sif, count); BlockPos.MutableBlockPos genPos = new BlockPos.MutableBlockPos(pos); for (int i = 0; i < count; i++) { genPos.setY(pos.getY() + i); world.setBlockState(genPos, BlockRegistry.crystal.getDefaultState(), 2); TileSingleSip tss = new TileSingleSip(); tss.setType(sipType, false); world.setTileEntity(genPos, tss); } PurMag.INSTANCE.debug("Crystal " + sipType + " " + pos); predicate.afterPlace(random, chunkX, chunkZ, world, chunkGenerator, chunkProvider, pos, sif, count); } } }
@Override public void beforePlace(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider, BlockPos pos, float sif, int count) { BlockPos.MutableBlockPos p = new BlockPos.MutableBlockPos(pos); for (int y1 = 0; y1 < count + 1; y1++) { p.setY(p.getY() + y1); world.setBlockToAir(p); } }
@Override public int getY(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider, int x, int z, float sif) { BlockPos.MutableBlockPos mut = new BlockPos.MutableBlockPos(x, 0, z); for (int y = 0; y < 256; y++) { mut.setY(y); if (world.isAirBlock(mut)) { return y; } } return -1; }
@Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) { switch (world.provider.getDimension()){ case -1: break; case 0: this.runGenerator(this.gen_green_shard_ore, world, random, chunkX, chunkZ, 20,0, 60); break; case 1: break; } }