Skip to content

Commit

Permalink
Clean up remaining generators
Browse files Browse the repository at this point in the history
  • Loading branch information
ACGaming committed May 4, 2024
1 parent 69602dd commit d096562
Show file tree
Hide file tree
Showing 19 changed files with 318 additions and 459 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ public static boolean syncConfig()
public static int amaranthRarity = 1;
public static int tigerRarity = 30;
public static int willowRarity = 10;
public static int eucalyptusSpawnRarity = 40;
public static int eucalyptusSpawnRarity = 30;
public static int eucalyptusSpawnRange = 32;
public static int hopseedSpawnRarity = 10;
public static int hopseedSpawnRange = 20;
Expand Down
25 changes: 8 additions & 17 deletions src/main/java/com/progwml6/natura/world/NaturaWorld.java
Original file line number Diff line number Diff line change
@@ -1,29 +1,20 @@
package com.progwml6.natura.world;

import org.apache.logging.log4j.Logger;

import com.google.common.eventbus.Subscribe;
import com.progwml6.natura.common.CommonProxy;
import com.progwml6.natura.common.NaturaPulse;
import com.progwml6.natura.common.config.Config;
import com.progwml6.natura.library.Util;
import com.progwml6.natura.world.worldgen.CloudGenerator;
import com.progwml6.natura.world.worldgen.CropGenerator;
import com.progwml6.natura.world.worldgen.GlowshroomGenerator;
import com.progwml6.natura.world.worldgen.NetherBerryBushesGenerator;
import com.progwml6.natura.world.worldgen.NetherMinableGenerator;
import com.progwml6.natura.world.worldgen.NetherTreesGenerator;
import com.progwml6.natura.world.worldgen.OverworldBerryBushesGenerator;
import com.progwml6.natura.world.worldgen.OverworldTreesGenerator;
import com.progwml6.natura.world.worldgen.VineGenerator;
import com.progwml6.natura.world.worldgen.retrogen.TickHandlerWorldRetrogen;

import org.apache.logging.log4j.Logger;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;

import com.progwml6.natura.common.CommonProxy;
import com.progwml6.natura.common.NaturaPulse;
import com.progwml6.natura.common.config.Config;
import com.progwml6.natura.library.Util;
import com.progwml6.natura.world.worldgen.*;
import com.progwml6.natura.world.worldgen.retrogen.TickHandlerWorldRetrogen;
import slimeknights.mantle.pulsar.pulse.Pulse;

@Pulse(id = NaturaWorld.PulseId, description = "Everything that's found in the world and worldgen including the netherite dimension")
Expand Down
38 changes: 23 additions & 15 deletions src/main/java/com/progwml6/natura/world/WorldEvents.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package com.progwml6.natura.world;

import com.progwml6.natura.Natura;
import com.progwml6.natura.overworld.NaturaOverworld;
import com.progwml6.natura.shared.NaturaCommons;
import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.ai.EntityAITempt;
Expand All @@ -16,21 +13,31 @@
import net.minecraftforge.event.entity.player.PlayerInteractEvent.EntityInteract;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

public class WorldEvents {
import com.progwml6.natura.Natura;
import com.progwml6.natura.overworld.NaturaOverworld;
import com.progwml6.natura.shared.NaturaCommons;

public class WorldEvents
{
// Broken?
@SubscribeEvent
public void interactEvent(EntityInteract event) {
if (event.getTarget() instanceof EntityCow || event.getTarget() instanceof EntitySheep) {
public void interactEvent(EntityInteract event)
{
if (event.getTarget() instanceof EntityCow || event.getTarget() instanceof EntitySheep)
{
ItemStack equipped = event.getEntityPlayer().getHeldItem(event.getHand());
EntityAnimal creature = (EntityAnimal) event.getTarget();

if (equipped != null && equipped == NaturaCommons.barley && creature.getGrowingAge() == 0 && !creature.isInLove()) {
if (equipped == NaturaCommons.barley && creature.getGrowingAge() == 0 && !creature.isInLove())
{
EntityPlayer player = event.getEntityPlayer();

if (!player.capabilities.isCreativeMode) {
if (!player.capabilities.isCreativeMode)
{
equipped.shrink(1);

if (equipped.getCount() <= 0) {
if (equipped.getCount() <= 0)
{
player.inventory.setInventorySlotContents(player.inventory.currentItem, ItemStack.EMPTY);
}
}
Expand All @@ -42,15 +49,16 @@ public void interactEvent(EntityInteract event) {

// Broken?
@SubscribeEvent
public void onLivingJoin(EntityJoinWorldEvent event) {
if (event.getEntity() instanceof EntityCow || event.getEntity() instanceof EntitySheep) {
public void onLivingJoin(EntityJoinWorldEvent event)
{
if (event.getEntity() instanceof EntityCow || event.getEntity() instanceof EntitySheep)
{
((EntityLiving) event.getEntity()).tasks.addTask(3, new EntityAITempt((EntityCreature) event.getEntity(), 0.25F, NaturaCommons.materials, false));
}

if (Natura.pulseManager.isPulseLoaded(NaturaOverworld.PulseId)) {
if (event.getEntity() instanceof EntityChicken) {
((EntityLiving) event.getEntity()).tasks.addTask(3, new EntityAITempt((EntityCreature) event.getEntity(), 0.25F, NaturaOverworld.overworldSeeds, false));
}
if (Natura.pulseManager.isPulseLoaded(NaturaOverworld.PulseId) && event.getEntity() instanceof EntityChicken)
{
((EntityLiving) event.getEntity()).tasks.addTask(3, new EntityAITempt((EntityCreature) event.getEntity(), 0.25F, NaturaOverworld.overworldSeeds, false));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@

import java.util.Random;

import com.progwml6.natura.common.config.Config;
import com.progwml6.natura.shared.NaturaCommons;
import com.progwml6.natura.shared.block.clouds.BlockCloud;
import com.progwml6.natura.world.worldgen.clouds.CloudsGenerator;

import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Biomes;
import net.minecraft.util.math.BlockPos;
Expand All @@ -16,9 +11,14 @@
import net.minecraft.world.gen.IChunkGenerator;
import net.minecraftforge.fml.common.IWorldGenerator;

import com.progwml6.natura.common.config.Config;
import com.progwml6.natura.shared.NaturaCommons;
import com.progwml6.natura.shared.block.clouds.BlockCloud;
import com.progwml6.natura.world.worldgen.clouds.CloudsGenerator;

public class CloudGenerator implements IWorldGenerator
{
public static CloudGenerator INSTANCE = new CloudGenerator();
public static final CloudGenerator INSTANCE = new CloudGenerator();

//@formatter:off
CloudsGenerator smallWhiteCloudGen;
Expand Down Expand Up @@ -93,7 +93,9 @@ public void retroGen(Random random, int chunkX, int chunkZ, World world)

public void generateOverworld(Random random, int chunkX, int chunkZ, World world)
{
int xSpawn, ySpawn, zSpawn;
int xSpawn;
int ySpawn;
int zSpawn;

int xPos = chunkX * 16 + 8;
int zPos = chunkZ * 16 + 8;
Expand All @@ -104,11 +106,6 @@ public void generateOverworld(Random random, int chunkX, int chunkZ, World world

Biome biome = world.getChunk(chunkPos).getBiome(chunkPos, world.getBiomeProvider());

if (biome == null)
{
return;
}

if (Config.generateOverworldClouds && biome.getRainfall() > 0.15f && random.nextInt(Config.cloudSpawnRarity) == 0 && world.provider.getDimension() != 1 && this.shouldGenerateInDimension(world.provider.getDimension(), Config.cloudBlacklist))
{
xSpawn = xPos + random.nextInt(16);
Expand Down Expand Up @@ -139,22 +136,15 @@ else if (size < 11)

public void generateNether(Random random, int chunkX, int chunkZ, World world)
{
int xSpawn, ySpawn, zSpawn;
int xSpawn;
int ySpawn;
int zSpawn;

int xPos = chunkX * 16 + 8;
int zPos = chunkZ * 16 + 8;

BlockPos chunkPos = new BlockPos(xPos, 0, zPos);

BlockPos position;

Biome biome = world.getChunk(chunkPos).getBiome(chunkPos, world.getBiomeProvider());

if (biome == null)
{
return;
}

if (world.provider.doesWaterVaporize())
{
if (Config.generateAshClouds && random.nextInt(Config.ashSpawnRarity) == 0 && this.shouldGenerateInDimension(world.provider.getDimension(), Config.ashBlacklist))
Expand Down Expand Up @@ -223,7 +213,9 @@ else if (size < 11)

public void generateEnd(Random random, int chunkX, int chunkZ, World world)
{
int xSpawn, ySpawn, zSpawn;
int xSpawn;
int ySpawn;
int zSpawn;

int xPos = chunkX * 16 + 8;
int zPos = chunkZ * 16 + 8;
Expand All @@ -234,11 +226,6 @@ public void generateEnd(Random random, int chunkX, int chunkZ, World world)

Biome biome = world.getChunk(chunkPos).getBiome(chunkPos, world.getBiomeProvider());

if (biome == null)
{
return;
}

if (Config.generateDarkClouds && biome == Biomes.SKY && world.provider.getDimension() == 1 && random.nextInt(4) == 0 && this.shouldGenerateInDimension(world.provider.getDimension(), Config.darkCloudBlacklist))
{
xSpawn = xPos + random.nextInt(16);
Expand Down
53 changes: 15 additions & 38 deletions src/main/java/com/progwml6/natura/world/worldgen/CropGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@

import java.util.Random;

import com.progwml6.natura.common.config.Config;
import com.progwml6.natura.overworld.NaturaOverworld;
import com.progwml6.natura.overworld.block.crops.BlockNaturaBarley;
import com.progwml6.natura.overworld.block.crops.BlockNaturaCotton;

import net.minecraft.block.state.IBlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
Expand All @@ -15,9 +10,14 @@
import net.minecraft.world.gen.IChunkGenerator;
import net.minecraftforge.fml.common.IWorldGenerator;

import com.progwml6.natura.common.config.Config;
import com.progwml6.natura.overworld.NaturaOverworld;
import com.progwml6.natura.overworld.block.crops.BlockNaturaBarley;
import com.progwml6.natura.overworld.block.crops.BlockNaturaCotton;

public class CropGenerator implements IWorldGenerator
{
public static CropGenerator INSTANCE = new CropGenerator();
public static final CropGenerator INSTANCE = new CropGenerator();

@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider)
Expand Down Expand Up @@ -50,13 +50,9 @@ public void generateOverworld(Random random, int chunkX, int chunkZ, World world
final int posY = random.nextInt(128) + Config.seaLevel;
final int posZ = zPos + random.nextInt(16);
final BlockPos newPos = new BlockPos(posX, posY, posZ);
//final BlockPos newPos = WorldGenHelper.getGroundPos(world, posX, posZ);

if (newPos != null)
{
this.generateBarley(world, random, newPos);
this.generateBarley(world, random, newPos);
}
this.generateBarley(world, random, newPos);
this.generateBarley(world, random, newPos);
}

// Cotton
Expand All @@ -66,13 +62,9 @@ public void generateOverworld(Random random, int chunkX, int chunkZ, World world
final int posZ = zPos + random.nextInt(16);
final int posY = random.nextInt(128) + Config.seaLevel;
final BlockPos newPos = new BlockPos(posX, posY, posZ);
//final BlockPos newPos = WorldGenHelper.getGroundPos(world, posX, posZ);

if (newPos != null)
{
this.generateCotton(world, random, newPos);
this.generateCotton(world, random, newPos);
}
this.generateCotton(world, random, newPos);
this.generateCotton(world, random, newPos);
}

// Bluebells
Expand All @@ -82,17 +74,13 @@ public void generateOverworld(Random random, int chunkX, int chunkZ, World world
final int posZ = zPos + random.nextInt(16);
final int posY = random.nextInt(128) + Config.seaLevel;
final BlockPos newPos = new BlockPos(posX, posY, posZ);
//final BlockPos newPos = WorldGenHelper.getGroundPos(world, posX, posZ);

if (newPos != null)
{
this.generateBluebells(world, random, newPos);
}
this.generateBluebells(world, random, newPos);
}
}
}

public boolean generateBarley(World world, Random random, BlockPos position)
public void generateBarley(World world, Random random, BlockPos position)
{
IBlockState state = NaturaOverworld.barleyCrop.getDefaultState().withProperty(BlockNaturaBarley.AGE, 3);

Expand All @@ -105,11 +93,9 @@ public boolean generateBarley(World world, Random random, BlockPos position)
world.setBlockState(blockpos, state, 2);
}
}

return true;
}

public boolean generateCotton(World world, Random random, BlockPos position)
public void generateCotton(World world, Random random, BlockPos position)
{
IBlockState state = NaturaOverworld.cottonCrop.getDefaultState().withProperty(BlockNaturaCotton.AGE, 4);

Expand All @@ -122,11 +108,9 @@ public boolean generateCotton(World world, Random random, BlockPos position)
world.setBlockState(blockpos, state, 2);
}
}

return true;
}

public boolean generateBluebells(World world, Random random, BlockPos position)
public void generateBluebells(World world, Random random, BlockPos position)
{
IBlockState state = NaturaOverworld.bluebellsFlower.getDefaultState();

Expand All @@ -139,21 +123,14 @@ public boolean generateBluebells(World world, Random random, BlockPos position)
world.setBlockState(blockpos, state, 2);
}
}

return true;
}

public boolean goodClimate(Biome biome, float minTemp, float maxTemp, float minRain, float maxRain)
{
float temp = biome.getDefaultTemperature();
float rain = biome.getRainfall();

if (minTemp <= temp && temp <= maxTemp && minRain <= rain && rain <= maxRain)
{
return true;
}

return false;
return minTemp <= temp && temp <= maxTemp && minRain <= rain && rain <= maxRain;
}

public boolean shouldGenerateInDimension(int dimension)
Expand Down
Loading

0 comments on commit d096562

Please sign in to comment.