Java Code Examples for net.minecraftforge.event.terraingen.PopulateChunkEvent#Post

The following examples show how to use net.minecraftforge.event.terraingen.PopulateChunkEvent#Post . 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: OilGeneratorFix.java    From NewHorizonsCoreMod with GNU General Public License v3.0 5 votes vote down vote up
@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 2
Source File: PlanetEventHandler.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
@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 3
Source File: GTEventPopulateChunk.java    From GT-Classic with GNU Lesser General Public License v3.0 4 votes vote down vote up
@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 4
Source File: CivilizationGeneratorHandlers.java    From ToroQuest with GNU General Public License v3.0 4 votes vote down vote up
@SubscribeEvent
public void registerNewCiviliationBorder(PopulateChunkEvent.Post event) {
	registerCiv(event);
}
 
Example 5
Source File: MapGenLander.java    From AdvancedRocketry with MIT License 4 votes vote down vote up
@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());
	}
}