net.minecraftforge.event.terraingen.PopulateChunkEvent Java Examples
The following examples show how to use
net.minecraftforge.event.terraingen.PopulateChunkEvent.
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: MoCChunkProviderWyvernLair.java From mocreaturesdev with GNU General Public License v3.0 | 6 votes |
/** * Populates chunk with ores etc etc */ public void populate_old(IChunkProvider par1IChunkProvider, int par2, int par3) { BlockSand.fallInstantly = true; MinecraftForge.EVENT_BUS.post(new PopulateChunkEvent.Pre(par1IChunkProvider, worldObj, worldObj.rand, par2, par3, false)); int var4 = par2 * 16; int var5 = par3 * 16; BiomeGenBase var6 = this.worldObj.getBiomeGenForCoords(var4 + 16, var5 + 16); var6.decorate(this.worldObj, this.worldObj.rand, var4, var5); MinecraftForge.EVENT_BUS.post(new PopulateChunkEvent.Post(par1IChunkProvider, worldObj, worldObj.rand, par2, par3, false)); BlockSand.fallInstantly = false; }
Example #2
Source File: OilGeneratorFix.java From NewHorizonsCoreMod with GNU General Public License v3.0 | 5 votes |
@SubscribeEvent public void populate( PopulateChunkEvent.Post event ) { try { if( _mBuildCraftOilBlock == null ) { return; } int tMinDist = MainRegistry.CoreConfig.OilFixConfig.OilDepostMinDistance; if (tMinDist > 1) { if (event.chunkX % tMinDist != 0 || event.chunkZ % tMinDist != 0) { return; } } boolean doGen = TerrainGen.populate( event.chunkProvider, event.world, event.rand, event.chunkX, event.chunkZ, event.hasVillageGenerated, PopulateChunkEvent.Populate.EventType.CUSTOM ); if( !doGen ) { return; } int worldX = event.chunkX << 4; int worldZ = event.chunkZ << 4; generateOil( event.world, event.rand, worldX + event.rand.nextInt( 16 ), worldZ + event.rand.nextInt( 16 ), false ); } catch( Exception e ) { e.printStackTrace(); } }
Example #3
Source File: ChunkProviderTCOuter.java From Gadomancy with GNU Lesser General Public License v3.0 | 5 votes |
public void populate(IChunkProvider p_73153_1_, int p_73153_2_, int p_73153_3_) { net.minecraft.block.BlockFalling.fallInstantly = true; MinecraftForge.EVENT_BUS.post(new PopulateChunkEvent.Pre(p_73153_1_, this.worldObj, this.worldObj.rand, p_73153_2_, p_73153_3_, false)); int k = p_73153_2_ * 16; int l = p_73153_3_ * 16; BiomeGenBase biomegenbase = this.worldObj.getBiomeGenForCoords(k + 16, l + 16); biomegenbase.decorate(this.worldObj, this.worldObj.rand, k, l); MinecraftForge.EVENT_BUS.post(new PopulateChunkEvent.Post(p_73153_1_, this.worldObj, this.worldObj.rand, p_73153_2_, p_73153_3_, false)); net.minecraft.block.BlockFalling.fallInstantly = false; }
Example #4
Source File: PlanetEventHandler.java From AdvancedRocketry with MIT License | 5 votes |
@SubscribeEvent public void chunkLoadEvent(PopulateChunkEvent.Post event) { if(zmaster587.advancedRocketry.api.Configuration.allowTerraforming && event.getWorld().provider.getClass() == WorldProviderPlanet.class) { if(DimensionManager.getInstance().getDimensionProperties(event.getWorld().provider.getDimension()).isTerraformed()) { Chunk chunk = event.getWorld().getChunkFromChunkCoords(event.getChunkX(), event.getChunkZ()); modifyChunk(event.getWorld(), (WorldProviderPlanet) event.getWorld().provider, chunk); } } }
Example #5
Source File: MoCEventHooks.java From mocreaturesdev with GNU General Public License v3.0 | 5 votes |
@ForgeSubscribe public void peformCustomWorldGenSpawning(PopulateChunkEvent.Populate event) { int par1 = event.chunkX * 16; int par2 = event.chunkZ * 16; List customSpawnList = MoCreatures.myCustomSpawner.getCustomBiomeSpawnList(event.world.getBiomeGenForCoords(par1 + 16, par2 + 16)); CustomSpawner.performWorldGenSpawning(event.world, event.world.getBiomeGenForCoords(par1 + 16, par2 + 16), par1 + 8, par2 + 8, 16, 16, event.rand, customSpawnList); }
Example #6
Source File: ChunkProviderRoss128b.java From bartworks with MIT License | 4 votes |
@Override public void populate(IChunkProvider p_73153_1_, int p_73153_2_, int p_73153_3_) { BlockFalling.fallInstantly = true; int k = p_73153_2_ * 16; int l = p_73153_3_ * 16; BiomeGenBase biomegenbase = this.worldObj.getBiomeGenForCoords(k + 16, l + 16); this.rand.setSeed(this.worldObj.getSeed()); if (p_73153_2_ % 4 == 0 || p_73153_3_ % 4 == 0) { long i1 = this.rand.nextLong() / 2L * 2L + 1L; long j1 = this.rand.nextLong() / 2L * 2L + 1L; this.rand.setSeed((long) p_73153_2_ * i1 + (long) p_73153_3_ * j1 ^ this.worldObj.getSeed()); } MinecraftForge.EVENT_BUS.post(new PopulateChunkEvent.Pre(p_73153_1_, this.worldObj, this.rand, p_73153_2_, p_73153_3_, false)); int x1; int y1; int z1; if (biomegenbase != BiomeGenBase.desert && biomegenbase != BiomeGenBase.desertHills && TerrainGen.populate(p_73153_1_, this.worldObj, this.rand, p_73153_2_, p_73153_3_, false, LAKE)) { x1 = k + this.rand.nextInt(16) + 8; y1 = this.rand.nextInt(256); z1 = l + this.rand.nextInt(16) + 8; int rni = this.rand.nextInt(8); if (rni == 0) (new WorldGenLakes(Blocks.ice)).generate(this.worldObj, this.rand, x1, y1, z1); else if (rni == 4) (new WorldGenLakes(Blocks.water)).generate(this.worldObj, this.rand, x1, y1, z1); } if (biomegenbase != BiomeGenBase.ocean && biomegenbase != BiomeGenBase.deepOcean && biomegenbase != BiomeGenBase.river && biomegenbase != BiomeGenBase.frozenOcean && biomegenbase != BiomeGenBase.frozenRiver && this.rand.nextInt(ConfigHandler.ross128bRuinChance) == 0) { x1 = k + this.rand.nextInt(16) + 3; y1 = this.rand.nextInt(256); z1 = l + this.rand.nextInt(16) + 3; this.ruinsBase.generate(this.worldObj, this.rand, x1, y1, z1); } biomegenbase.decorate(this.worldObj, this.rand, k, l); k += 8; l += 8; boolean doGen = TerrainGen.populate(p_73153_1_, this.worldObj, this.rand, p_73153_2_, p_73153_3_, false, ICE); for (x1 = 0; doGen && x1 < 16; ++x1) { for (y1 = 0; y1 < 16; ++y1) { z1 = this.worldObj.getPrecipitationHeight(k + x1, l + y1); if (this.worldObj.isBlockFreezable(x1 + k, z1 - 1, y1 + l)) { this.worldObj.setBlock(x1 + k, z1 - 1, y1 + l, Blocks.ice, 0, 2); } if (this.worldObj.func_147478_e(x1 + k, z1, y1 + l, true)) { this.worldObj.setBlock(x1 + k, z1, y1 + l, Blocks.snow_layer, 0, 2); } } } BWOreGen.generate(this.rand, p_73153_2_, p_73153_3_, this.worldObj, this, this); MinecraftForge.EVENT_BUS.post(new PopulateChunkEvent.Post(p_73153_1_, this.worldObj, this.rand, p_73153_2_, p_73153_3_, false)); BlockFalling.fallInstantly = false; }
Example #7
Source File: GTEventPopulateChunk.java From GT-Classic with GNU Lesser General Public License v3.0 | 4 votes |
@SubscribeEvent(priority = EventPriority.NORMAL) public void onEvent(PopulateChunkEvent.Post event) { if (!event.getWorld().provider.getDimensionType().equals(DimensionType.OVERWORLD)) { return; } if (GTConfig.general.replaceOceanGravelWithSand) { Chunk chunk = event.getWorld().getChunkFromChunkCoords(event.getChunkX(), event.getChunkZ()); for (int x = 0; x < 16; ++x) { for (int z = 0; z < 16; ++z) { Biome biomegenbase = event.getWorld().getBiome(new BlockPos(chunk.x * 16 + x, 128, chunk.z * 16 + z)); if (BiomeDictionary.hasType(biomegenbase, Type.OCEAN) || BiomeDictionary.hasType(biomegenbase, Type.BEACH)) { for (int y = 30; y < 60; ++y) { if (chunk.getBlockState(x, y, z).getBlock() == BLOCK_GRAVEL) { chunk.setBlockState(new BlockPos(x, y, z), BLOCK_SAND.getDefaultState()); } } } } } chunk.markDirty(); } // if (GTConfig.general.redSandInForestsAndPlains) { // Chunk chunk = event.getWorld().getChunkFromChunkCoords(event.getChunkX(), event.getChunkZ()); // for (int x = 0; x < 16; ++x) { // for (int z = 0; z < 16; ++z) { // Biome biomegenbase = event.getWorld().getBiome(new BlockPos(chunk.x * 16 + x, 128, chunk.z * 16 // + z)); // if (BiomeDictionary.hasType(biomegenbase, Type.FOREST) // || BiomeDictionary.hasType(biomegenbase, Type.PLAINS)) { // for (int y = 30; y < 80; ++y) { // if (chunk.getBlockState(x, y, z).getBlock() == BLOCK_SAND) { // chunk.setBlockState(new BlockPos(x, y, z), BLOCKSTATE_RED_SAND); // } // } // } // } // } // chunk.markDirty(); // } }
Example #8
Source File: CivilizationGeneratorHandlers.java From ToroQuest with GNU General Public License v3.0 | 4 votes |
@SubscribeEvent public void registerNewCiviliationBorder(PopulateChunkEvent.Post event) { registerCiv(event); }
Example #9
Source File: CivilizationGeneratorHandlers.java From ToroQuest with GNU General Public License v3.0 | 4 votes |
@SubscribeEvent public void registerNewCiviliationBorder(PopulateChunkEvent.Pre event) { registerCiv(event); }
Example #10
Source File: CivilizationGeneratorHandlers.java From ToroQuest with GNU General Public License v3.0 | 4 votes |
protected void registerCiv(PopulateChunkEvent event) { if (!event.isHasVillageGenerated()) { return; } CivilizationUtil.registerNewCivilization(event.getWorld(), event.getChunkX(), event.getChunkZ()); }
Example #11
Source File: NH_QuarryPopulator.java From NewHorizonsCoreMod with GNU General Public License v3.0 | 4 votes |
@SubscribeEvent public void generate(PopulateChunkEvent.Pre event) { if(TerrainGen.populate(event.chunkProvider, event.world, event.rand, event.chunkX, event.chunkZ, event.hasVillageGenerated, EVENT_TYPE)) { generateQuarry(event.world, event.rand, event.chunkX, event.chunkZ); } }
Example #12
Source File: NH_GeodePopulator.java From NewHorizonsCoreMod with GNU General Public License v3.0 | 4 votes |
@SubscribeEvent public void generate(PopulateChunkEvent.Pre event) { if(TerrainGen.populate(event.chunkProvider, event.world, event.rand, event.chunkX, event.chunkZ, event.hasVillageGenerated, EVENT_TYPE)) { generateGeode(event.world, event.rand, event.chunkX, event.chunkZ); } }
Example #13
Source File: MapGenLander.java From AdvancedRocketry with MIT License | 4 votes |
@SubscribeEvent public void populateChunkPostEvent(PopulateChunkEvent.Post event) { World worldIn = event.getWorld(); BlockPos position = new BlockPos(16*event.getChunkX() + 3,0, 16*event.getChunkZ() + 11); if(DimensionManager.getInstance().getDimensionProperties(worldIn.provider.getDimension()).getName().equals("Luna") && position.getX() == 67 && position.getZ() == 2347) { position = worldIn.getHeight(position).down(); worldIn.setBlockState(position.add(0, 0, 3), Blocks.STONE_SLAB.getDefaultState().withProperty(BlockSlab.HALF, EnumBlockHalf.TOP)); worldIn.setBlockState(position.add(0, 0, -3), Blocks.STONE_SLAB.getDefaultState().withProperty(BlockSlab.HALF, EnumBlockHalf.TOP)); worldIn.setBlockState(position.add(3, 0, 0), Blocks.STONE_SLAB.getDefaultState().withProperty(BlockSlab.HALF, EnumBlockHalf.TOP)); worldIn.setBlockState(position.add(-3, 0, 0), Blocks.STONE_SLAB.getDefaultState().withProperty(BlockSlab.HALF, EnumBlockHalf.TOP)); position = position.up(); worldIn.setBlockState(position, AdvancedRocketryBlocks.blockEngine.getDefaultState()); worldIn.setBlockState(position.add(0, 0, 3), Blocks.IRON_BARS.getDefaultState()); worldIn.setBlockState(position.add(0, 0, -3), Blocks.IRON_BARS.getDefaultState()); worldIn.setBlockState(position.add(3, 0, 0), Blocks.IRON_BARS.getDefaultState()); worldIn.setBlockState(position.add(-3, 0, 0), Blocks.IRON_BARS.getDefaultState()); position = position.up(); worldIn.setBlockState(position.add(0, 0, 3), Blocks.IRON_BARS.getDefaultState()); worldIn.setBlockState(position.add(0, 0, -3), Blocks.IRON_BARS.getDefaultState()); worldIn.setBlockState(position.add(3, 0, 0), Blocks.IRON_BARS.getDefaultState()); worldIn.setBlockState(position.add(-3, 0, 0), Blocks.IRON_BARS.getDefaultState()); for(int x = -1; x <= 1; x++ ) { worldIn.setBlockState(position.add(-2, 0, x), Blocks.GOLD_BLOCK.getDefaultState()); worldIn.setBlockState(position.add(2, 0, x), Blocks.GOLD_BLOCK.getDefaultState()); worldIn.setBlockState(position.add(x, 0, -2), Blocks.GOLD_BLOCK.getDefaultState()); worldIn.setBlockState(position.add(x, 0, 2), Blocks.GOLD_BLOCK.getDefaultState()); for(int z = -1; z <= 1; z++) { worldIn.setBlockState(position.add(x, 0, z), Blocks.IRON_BLOCK.getDefaultState()); } } position = position.up(); worldIn.setBlockState(position.add(0, 0, 3), Blocks.IRON_BARS.getDefaultState()); worldIn.setBlockState(position.add(0, 0, -3), Blocks.IRON_BARS.getDefaultState()); worldIn.setBlockState(position.add(3, 0, 0), Blocks.IRON_BARS.getDefaultState()); worldIn.setBlockState(position.add(-3, 0, 0), Blocks.IRON_BARS.getDefaultState()); for(int x = -1; x <= 1; x++ ) { worldIn.setBlockState(position.add(-2, 0, x), Blocks.GOLD_BLOCK.getDefaultState()); worldIn.setBlockState(position.add(2, 0, x), Blocks.GOLD_BLOCK.getDefaultState()); worldIn.setBlockState(position.add(x, 0, -2), Blocks.GOLD_BLOCK.getDefaultState()); worldIn.setBlockState(position.add(x, 0, 2), Blocks.GOLD_BLOCK.getDefaultState()); } worldIn.setBlockState(position.add(0, 0, 1), Blocks.IRON_BLOCK.getDefaultState()); worldIn.setBlockState(position.add(1, 0, 0), Blocks.IRON_BLOCK.getDefaultState()); worldIn.setBlockState(position.add(0, 0, -1), Blocks.IRON_BLOCK.getDefaultState()); worldIn.setBlockState(position.add(-1, 0, 0), Blocks.IRON_BLOCK.getDefaultState()); position = worldIn.getHeight(position.add(10,0,15)); for(int x = 0; x <= 4; x++ ) worldIn.setBlockState(position.add(0,x,0), Blocks.IRON_BARS.getDefaultState()); worldIn.setBlockState(position.add(1,4,0), Blocks.IRON_BARS.getDefaultState()); worldIn.setBlockState(position.add(2,4,0), Blocks.IRON_BARS.getDefaultState()); } }
Example #14
Source File: ChunkProviderSurface.java From TFC2 with GNU General Public License v3.0 | 4 votes |
@Override public void populate(int x, int z) { net.minecraft.block.BlockFalling.fallInstantly = true; BlockPos blockpos = new BlockPos(x * 16, 0, z * 16); Biome Biome = this.worldObj.getBiome(blockpos.add(16, 0, 16)); this.rand.setSeed(this.worldObj.getSeed()); long k = this.rand.nextLong() / 2L * 2L + 1L; long l = this.rand.nextLong() / 2L * 2L + 1L; this.rand.setSeed(x * k + z * l ^ this.worldObj.getSeed()); boolean flag = false; ChunkPos ChunkPos = new ChunkPos(x, z); ForgeEventFactory.onChunkPopulate(true, this, this.worldObj, x, z, flag); TerrainGen.populate(this, this.worldObj, this.rand, x, z, flag, PopulateChunkEvent.Populate.EventType.LAKE); TerrainGen.populate(this, this.worldObj, this.rand, x, z, flag, PopulateChunkEvent.Populate.EventType.LAVA); Biome.decorate(this.worldObj, this.rand, new BlockPos(x * 16, 0, z * 16)); if(TerrainGen.populate(this, this.worldObj, this.rand, x, z, flag, PopulateChunkEvent.Populate.EventType.ANIMALS)) { BlockPos chunkWorldPos = new BlockPos(x * 16, 0, z * 16); worldX = x * 16; worldZ = z * 16; islandChunkX = worldX % MAP_SIZE; islandChunkZ = worldZ % MAP_SIZE; Point islandPos = new Point(islandChunkX, islandChunkZ).toIslandCoord(); IslandMap map = Core.getMapForWorld(worldObj, chunkWorldPos); Center centerInChunk = null; Center temp = map.getClosestCenter(islandPos); if(Core.isCenterInRect(temp, (int)islandPos.x, (int)islandPos.y, 16, 16)) centerInChunk = temp; else { temp = map.getClosestCenter(islandPos.plus(15, 0)); if(Core.isCenterInRect(temp, (int)islandPos.x, (int)islandPos.y, 16, 16)) centerInChunk = temp; else { temp = map.getClosestCenter(islandPos.plus(0, 15)); if(Core.isCenterInRect(temp, (int)islandPos.x, (int)islandPos.y, 16, 16)) centerInChunk = temp; else { temp = map.getClosestCenter(islandPos.plus(15, 15)); if(Core.isCenterInRect(temp, (int)islandPos.x, (int)islandPos.y, 16, 16)) centerInChunk = temp; } } } } blockpos = blockpos.add(8, 0, 8); if (TerrainGen.populate(this, this.worldObj, this.rand, x, z, flag, PopulateChunkEvent.Populate.EventType.ICE)) { for (int k2 = 0; k2 < 16; k2++) { for (int j3 = 0; j3 < 16; j3++) { BlockPos blockpos1 = this.worldObj.getPrecipitationHeight(blockpos.add(k2, 0, j3)); BlockPos blockpos2 = blockpos1.down(); if (this.worldObj.canBlockFreezeWater(blockpos2)) { this.worldObj.setBlockState(blockpos2, Blocks.ICE.getDefaultState(), 2); } if (this.worldObj.canSnowAt(blockpos1, true)) { this.worldObj.setBlockState(blockpos1, Blocks.SNOW_LAYER.getDefaultState(), 2); } } } } ForgeEventFactory.onChunkPopulate(false, this, this.worldObj, x, z, flag); net.minecraft.block.BlockFalling.fallInstantly = false; }
Example #15
Source File: MoCChunkProviderWyvernLair.java From mocreaturesdev with GNU General Public License v3.0 | 4 votes |
/** * Populates chunk with ores etc etc */ public void populate(IChunkProvider par1IChunkProvider, int par2, int par3) { BlockSand.fallInstantly = true; MinecraftForge.EVENT_BUS.post(new PopulateChunkEvent.Pre(par1IChunkProvider, worldObj, worldObj.rand, par2, par3, false)); int var4 = par2 * 16; int var5 = par3 * 16; BiomeGenBase var6 = this.worldObj.getBiomeGenForCoords(var4 + 16, var5 + 16); //this.RNGa.setSeed(this.worldObj.getSeed()); long var7 = this.RNGa.nextLong() / 2L * 2L + 1L; long var9 = this.RNGa.nextLong() / 2L * 2L + 1L; //this.RNGa.setSeed((long)par2 * var7 + (long)par3 * var9 ^ this.worldObj.getSeed()); boolean var11 = false; int var12; int var13; int var14; if (!var11 && this.RNGa.nextInt(2) == 0) { var12 = var4 + this.RNGa.nextInt(16) + 8; var13 = this.RNGa.nextInt(128); var14 = var5 + this.RNGa.nextInt(16) + 8; (new WorldGenLakes(Block.waterStill.blockID)).generate(this.worldObj, this.RNGa, var12, var13, var14); } if (!var11 && this.RNGa.nextInt(8) == 0) { var12 = var4 + this.RNGa.nextInt(16) + 8; var13 = this.RNGa.nextInt(this.RNGa.nextInt(120) + 8); var14 = var5 + this.RNGa.nextInt(16) + 8; if (var13 < 63 || this.RNGa.nextInt(10) == 0) { (new WorldGenLakes(Block.lavaStill.blockID)).generate(this.worldObj, this.RNGa, var12, var13, var14); } } var6.decorate(this.worldObj, this.RNGa, var4, var5); SpawnerAnimals.performWorldGenSpawning(this.worldObj, var6, var4 + 8, var5 + 8, 16, 16, this.RNGa); if (!portalDone) createPortal(this.worldObj, this.RNGa); /* while(!portalDone) { createPortal(this.worldObj, this.RNGa); } */ MinecraftForge.EVENT_BUS.post(new PopulateChunkEvent.Post(par1IChunkProvider, worldObj, worldObj.rand, par2, par3, false)); BlockSand.fallInstantly = false; }