net.minecraftforge.event.terraingen.OreGenEvent Java Examples

The following examples show how to use net.minecraftforge.event.terraingen.OreGenEvent. 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: PlanetEventHandler.java    From AdvancedRocketry with MIT License 6 votes vote down vote up
@SubscribeEvent
public void onWorldGen(OreGenEvent.GenerateMinable event) {

	if(event.getWorld().provider instanceof WorldProviderPlanet && 
			DimensionManager.getInstance().getDimensionProperties(event.getWorld().provider.getDimension()).getOreGenProperties(event.getWorld()) != null) {

		switch(event.getType()) {
		case COAL:
		case DIAMOND:
		case EMERALD:
		case GOLD:
		case IRON:
		case LAPIS:
		case QUARTZ:
		case REDSTONE:
		case CUSTOM:
			event.setResult(Result.DENY);
			break;
		default:
			event.setResult(Result.DEFAULT);
		}
	}
}
 
Example #2
Source File: ChunkProviderTofu.java    From TofuCraftReload with MIT License 5 votes vote down vote up
@Override
public void populate(int x, int z) {
    BlockFalling.fallInstantly = true;
    BlockPos blockpos = new BlockPos(x * 16, 0, z * 16);

    Biome biome = this.world.getBiome(blockpos.add(16, 0, 16));

    rand.setSeed(world.getSeed());
    long xSeed = rand.nextLong() / 2L * 2L + 1L;
    long zSeed = rand.nextLong() / 2L * 2L + 1L;
    rand.setSeed(chunkX * xSeed + chunkZ * zSeed ^ world.getSeed());

    int i = x * 16;
    int j = z * 16;

    if (net.minecraftforge.event.terraingen.TerrainGen.generateOre(this.world, this.rand, diamondGen, blockpos, OreGenEvent.GenerateMinable.EventType.CUSTOM))
        for (int l1 = 0; l1 < 12; ++l1)
        {
            this.diamondGen.generate(this.world, this.rand, blockpos.add(this.rand.nextInt(16), this.rand.nextInt(30), this.rand.nextInt(16)));
        }


    ChunkPos chunkpos = new ChunkPos(x, z);

    if (mapFeaturesEnabled) {
        this.mineshaft.generateStructure(this.world, this.rand, chunkpos);
        this.villageGenerator.generateStructure(this.world, this.rand, chunkpos);
        this.tofuCastle.generateStructure(this.world, this.rand, chunkpos);
    }

    biome.decorate(world, rand, blockpos);


    if (net.minecraftforge.event.terraingen.TerrainGen.populate(this, this.world, this.rand, x, z, false, net.minecraftforge.event.terraingen.PopulateChunkEvent.Populate.EventType.ANIMALS))
        WorldEntitySpawner.performWorldGenSpawning(this.world, biome, i + 8, j + 8, 16, 16, this.rand);

    net.minecraftforge.event.ForgeEventFactory.onChunkPopulate(false, this, this.world, this.rand, x, z, false);

    BlockFalling.fallInstantly = false;
}
 
Example #3
Source File: WorldGenLoader.java    From Sakura_mod with MIT License 5 votes vote down vote up
@SubscribeEvent
public void onOreGen(OreGenEvent.Post event) {
	World worldIn = event.getWorld();
       int genY = 10 + event.getRand().nextInt(24);
	if (SakuraConfig.every_where_sakura_diamond||(worldIn.getBiome(new BlockPos(event.getPos().getX(), 0, event.getPos().getZ())) == SakuraBiomes.BAMBOOFOREST ||
		worldIn.getBiome(new BlockPos(event.getPos().getX(), 0, event.getPos().getZ())) == SakuraBiomes.MAPLEFOREST)) {
		BlockPos pos=new BlockPos(event.getPos().getX(),genY, event.getPos().getZ());
               for (int i = 0; i < 2; i++) {
                   new WorldGenMinable(BlockLoader.SAKURA_DIAMOND_ORE.getDefaultState(),3 + event.getRand().nextInt(5)).generate(worldIn, event.getRand(), pos);
               }
       }
}
 
Example #4
Source File: WorldGeneratorImpl.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SubscribeEvent(priority = EventPriority.HIGH)
public void onOreGenerate(OreGenEvent.GenerateMinable event) {
    EventType eventType = event.getType();
    if (ConfigHolder.disableVanillaOres &&
        ORE_EVENT_TYPES.contains(eventType)) {
        event.setResult(Result.DENY);
    }
}
 
Example #5
Source File: OreGenerator.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
@Override
public void generate(Random random, int chunkX, int chunkZ, World world,
		IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) {
	
	OreGenEvent event = new OreGenEvent.GenerateMinable(world, random, this, new BlockPos(chunkX,0,chunkZ), EventType.CUSTOM);
	MinecraftForge.ORE_GEN_BUS.post(event);
	if(event.getResult() != Result.DENY) {
		if(Configuration.generateCopper) {
			generate(world, MaterialRegistry.getMaterialFromName("Copper"), Configuration.copperPerChunk, Configuration.copperClumpSize, chunkX, chunkZ, random);
		}

		if(Configuration.generateTin) {
			generate(world, MaterialRegistry.getMaterialFromName("Tin"), Configuration.tinPerChunk, Configuration.tinClumpSize, chunkX, chunkZ, random);
		}
		if(Configuration.generateRutile) {
			generate(world, MaterialRegistry.getMaterialFromName("Rutile"), Configuration.rutilePerChunk, Configuration.rutileClumpSize, chunkX, chunkZ, random);
		}
		if(Configuration.generateAluminum) {
			generate(world, MaterialRegistry.getMaterialFromName("Aluminum"), Configuration.aluminumPerChunk, Configuration.aluminumClumpSize, chunkX, chunkZ, random);
		}
		if(Configuration.generateIridium) {
			generate(world, MaterialRegistry.getMaterialFromName("Iridium"), Configuration.IridiumPerChunk, Configuration.IridiumClumpSize, chunkX, chunkZ, random);
		}

		if(Configuration.generateDilithium) {
			int dilithiumChance = Configuration.dilithiumPerChunk;
			if(world.provider instanceof WorldProviderPlanet) {
				dilithiumChance = DimensionProperties.AtmosphereTypes.getAtmosphereTypeFromValue(DimensionManager.getInstance().getDimensionProperties(world.provider.getDimension()).getAtmosphereDensity()) == DimensionProperties.AtmosphereTypes.NONE ? Configuration.dilithiumPerChunkMoon : Configuration.dilithiumPerChunk;;
			}
			
			for(int i = 0; i < dilithiumChance; i++) {
				int coordX = 16*chunkX + random.nextInt(16);
				int coordY = random.nextInt(64);
				int coordZ = 16*chunkZ + random.nextInt(16);

				new WorldGenMinable(MaterialRegistry.getMaterialFromName("Dilithium").getBlock().getDefaultState(), Configuration.dilithiumClumpSize).generate(world, random, new BlockPos(coordX, coordY, coordZ));
			}
		}
	}
}