From 136872eb11a9e77e35a844e78b8ebbf0b5dbef29 Mon Sep 17 00:00:00 2001 From: WhichOnesPink Date: Thu, 7 Jul 2016 06:27:09 +0100 Subject: [PATCH 01/22] Bumped to 1.0.2 --- build.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.properties b/build.properties index 44f782669..d2d5279a3 100644 --- a/build.properties +++ b/build.properties @@ -4,7 +4,7 @@ mod_id=RTG mod_name=Realistic Terrain Generation mod_desc=Adds a new world type which generates realistic terrain for Overworld biomes. -mod_version=1.0.1 +mod_version=1.0.2 mc_version=1.7.10 mod_url=https://github.com/Team-RTG/Realistic-Terrain-Generation mod_author="Team RTG" From f9c30375ea97393c26166bbc00c87a520e1822ea Mon Sep 17 00:00:00 2001 From: WhichOnesPink Date: Sat, 9 Jul 2016 19:42:06 +0100 Subject: [PATCH 02/22] Added new event handling system. --- src/main/java/rtg/RTG.java | 16 +- src/main/java/rtg/event/EventManagerRTG.java | 403 ++---------------- .../bus/event/worldevent/LoadChunkRTG.java | 28 ++ .../bus/event/worldevent/WorldLoadRTG.java | 38 ++ .../bus/event/worldevent/WorldUnloadRTG.java | 33 ++ .../oregenevent/GenerateMinableRTG.java | 73 ++++ .../biomeevent/GetVillageBlockRTG.java | 92 ++++ .../PreDecorateBiomeRTG.java | 28 ++ .../initmapgenevent/InitMapGenRTG.java | 53 +++ .../SaplingGrowTreeRTG.java | 132 ++++++ .../worldtypeevent/InitBiomeGensRTG.java | 33 ++ 11 files changed, 566 insertions(+), 363 deletions(-) create mode 100644 src/main/java/rtg/event/bus/event/worldevent/LoadChunkRTG.java create mode 100644 src/main/java/rtg/event/bus/event/worldevent/WorldLoadRTG.java create mode 100644 src/main/java/rtg/event/bus/event/worldevent/WorldUnloadRTG.java create mode 100644 src/main/java/rtg/event/bus/oregen/oregenevent/GenerateMinableRTG.java create mode 100644 src/main/java/rtg/event/bus/terraingen/biomeevent/GetVillageBlockRTG.java create mode 100644 src/main/java/rtg/event/bus/terraingen/decoratebiomeevent/PreDecorateBiomeRTG.java create mode 100644 src/main/java/rtg/event/bus/terraingen/initmapgenevent/InitMapGenRTG.java create mode 100644 src/main/java/rtg/event/bus/terraingen/saplinggrowtreeevent/SaplingGrowTreeRTG.java create mode 100644 src/main/java/rtg/event/bus/terraingen/worldtypeevent/InitBiomeGensRTG.java diff --git a/src/main/java/rtg/RTG.java b/src/main/java/rtg/RTG.java index 119725fe0..a6d7b6680 100755 --- a/src/main/java/rtg/RTG.java +++ b/src/main/java/rtg/RTG.java @@ -2,6 +2,7 @@ import java.util.ArrayList; +import net.minecraft.world.gen.structure.MapGenStructureIO; import net.minecraftforge.common.MinecraftForge; import rtg.api.event.BiomeConfigEvent; import rtg.config.BiomeConfigManager; @@ -29,6 +30,8 @@ import rtg.world.biome.realistic.tofucraft.RealisticBiomeTOFUBase; import rtg.world.biome.realistic.vampirism.RealisticBiomeVAMPBase; import rtg.world.biome.realistic.vanilla.RealisticBiomeVanillaBase; +import rtg.world.gen.structure.MapGenScatteredFeatureRTG; +import rtg.world.gen.structure.MapGenVillageRTG; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.Instance; @@ -54,14 +57,15 @@ public ConfigManager configManager(int dimension) { } @EventHandler - public void fmlLifeCycleEvent(FMLPreInitializationEvent event) + public void fmlLifeCycleEvent(FMLPreInitializationEvent event) { instance = this; - + + MapGenStructureIO.registerStructure(MapGenScatteredFeatureRTG.Start.class, "rtg_MapGenScatteredFeatureRTG"); + MapGenStructureIO.registerStructure(MapGenVillageRTG.Start.class, "rtg_MapGenVillageRTG"); + eventMgr = new EventManagerRTG(); - MinecraftForge.EVENT_BUS.register(eventMgr); - MinecraftForge.ORE_GEN_BUS.register(eventMgr); - MinecraftForge.TERRAIN_GEN_BUS.register(eventMgr); + eventMgr.registerEventHandlers(); MinecraftForge.EVENT_BUS.post(new BiomeConfigEvent.Pre()); @@ -110,7 +114,7 @@ public void fmlLifeCycle(FMLPostInitializationEvent event) RealisticBiomePresenceTester.doBiomeCheck(); } -/* FIXME: Why are we subscribing to events we don't do anything with? -srs_bsns +/* @EventHandler public void fmlLifeCycle(FMLServerAboutToStartEvent event) {} diff --git a/src/main/java/rtg/event/EventManagerRTG.java b/src/main/java/rtg/event/EventManagerRTG.java index 33ff796e8..57a523bf1 100755 --- a/src/main/java/rtg/event/EventManagerRTG.java +++ b/src/main/java/rtg/event/EventManagerRTG.java @@ -1,385 +1,74 @@ package rtg.event; -import java.util.ArrayList; -import java.util.Random; import java.util.WeakHashMap; -import net.minecraft.block.Block; -import net.minecraft.init.Blocks; -import net.minecraft.world.World; -import net.minecraft.world.biome.BiomeGenBase; -import net.minecraft.world.gen.structure.MapGenStructureIO; -import net.minecraftforge.common.BiomeDictionary; -import net.minecraftforge.common.BiomeDictionary.Type; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.terraingen.BiomeEvent; -import net.minecraftforge.event.terraingen.DecorateBiomeEvent; -import net.minecraftforge.event.terraingen.InitMapGenEvent; -import net.minecraftforge.event.terraingen.OreGenEvent; -import net.minecraftforge.event.terraingen.SaplingGrowTreeEvent; -import net.minecraftforge.event.terraingen.WorldTypeEvent; import net.minecraftforge.event.world.ChunkEvent; -import net.minecraftforge.event.world.WorldEvent; -import rtg.RTG; -import rtg.config.rtg.ConfigRTG; +import rtg.event.bus.event.worldevent.LoadChunkRTG; +import rtg.event.bus.event.worldevent.WorldLoadRTG; +import rtg.event.bus.event.worldevent.WorldUnloadRTG; +import rtg.event.bus.oregen.oregenevent.GenerateMinableRTG; +import rtg.event.bus.terraingen.biomeevent.GetVillageBlockRTG; +import rtg.event.bus.terraingen.decoratebiomeevent.PreDecorateBiomeRTG; +import rtg.event.bus.terraingen.initmapgenevent.InitMapGenRTG; +import rtg.event.bus.terraingen.saplinggrowtreeevent.SaplingGrowTreeRTG; +import rtg.event.bus.terraingen.worldtypeevent.InitBiomeGensRTG; import rtg.util.Acceptor; -import rtg.util.Logger; -import rtg.util.RandomUtil; -import rtg.world.WorldTypeRTG; -import rtg.world.biome.WorldChunkManagerRTG; import rtg.world.biome.realistic.RealisticBiomeBase; -import rtg.world.gen.MapGenCavesRTG; -import rtg.world.gen.MapGenRavineRTG; -import rtg.world.gen.feature.tree.rtg.TreeRTG; -import rtg.world.gen.genlayer.RiverRemover; -import rtg.world.gen.structure.MapGenScatteredFeatureRTG; -import rtg.world.gen.structure.MapGenVillageRTG; -import cpw.mods.fml.common.eventhandler.Event.Result; -import cpw.mods.fml.common.eventhandler.EventPriority; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; public class EventManagerRTG { - public RealisticBiomeBase biome = null; + public static LoadChunkRTG loadChunkRTG = new LoadChunkRTG(); + public static WorldLoadRTG worldLoadRTG = new WorldLoadRTG(); + public static WorldUnloadRTG worldUnloadRTG = new WorldUnloadRTG(); + public static GenerateMinableRTG generateMinableRTG = new GenerateMinableRTG(); + public static GetVillageBlockRTG getVillageBlockRTG = new GetVillageBlockRTG(); + public static PreDecorateBiomeRTG preDecorateBiomeRTG = new PreDecorateBiomeRTG(); + public static InitMapGenRTG initMapGenRTG = new InitMapGenRTG(); + public static SaplingGrowTreeRTG saplingGrowTreeRTG = new SaplingGrowTreeRTG(); + public static InitBiomeGensRTG initBiomeGensRTG = new InitBiomeGensRTG(); + + public RealisticBiomeBase biome = null; + private WeakHashMap> chunkLoadEvents = new WeakHashMap> (); public EventManagerRTG() { - MapGenStructureIO.registerStructure(MapGenScatteredFeatureRTG.Start.class, "rtg_MapGenScatteredFeatureRTG"); - MapGenStructureIO.registerStructure(MapGenVillageRTG.Start.class, "rtg_MapGenVillageRTG"); - } - - @SubscribeEvent(priority = EventPriority.LOW) - public void eventListenerRTG(InitMapGenEvent event) { - - Logger.debug("event type = %s", event.type.toString()); - Logger.debug("event originalGen = %s", event.originalGen.toString()); - - if (event.type == InitMapGenEvent.EventType.SCATTERED_FEATURE) { - event.newGen = new MapGenScatteredFeatureRTG(); - } - else if (event.type == InitMapGenEvent.EventType.VILLAGE) { - - if (ConfigRTG.enableVillageModifications) { - event.newGen = new MapGenVillageRTG(); - } - } - else if (event.type == InitMapGenEvent.EventType.CAVE) { - - if (ConfigRTG.enableCaveModifications) { - - event.newGen = new MapGenCavesRTG(); - } - } - else if (event.type == InitMapGenEvent.EventType.RAVINE) { - - if (ConfigRTG.enableRavineModifications) { - - event.newGen = new MapGenRavineRTG(); - } - } - - Logger.debug("event newGen = %s", event.newGen.toString()); - } - - @SubscribeEvent - public void eventListenerRTG(WorldEvent.Load event) { - - if (!(event.world.getWorldInfo().getTerrainType() instanceof WorldTypeRTG)) { - - MinecraftForge.TERRAIN_GEN_BUS.unregister(RTG.eventMgr); - MinecraftForge.ORE_GEN_BUS.unregister(RTG.eventMgr); - MinecraftForge.EVENT_BUS.unregister(RTG.eventMgr); - } - } - - @SubscribeEvent - public void onGenerateMinable(OreGenEvent.GenerateMinable event) { - - switch (event.type) { - - case COAL: - - if (!ConfigRTG.generateOreCoal) { - event.setResult(Result.DENY); - } - - break; - - case IRON: - - if (!ConfigRTG.generateOreIron) { - event.setResult(Result.DENY); - } - - break; - - case GOLD: - - if (!ConfigRTG.generateOreGold) { - event.setResult(Result.DENY); - } - - break; - - case DIAMOND: - - if (!ConfigRTG.generateOreDiamond) { - event.setResult(Result.DENY); - } - - break; - - case REDSTONE: - - if (!ConfigRTG.generateOreRedstone) { - event.setResult(Result.DENY); - } - - break; - - case LAPIS: - - if (!ConfigRTG.generateOreLapis) { - event.setResult(Result.DENY); - } - - break; - - default: - break; - } - } - - @SubscribeEvent - public void onBiomeGenInit(WorldTypeEvent.InitBiomeGens event) { - - // only handle RTG world type - if (!event.worldType.getWorldTypeName().equalsIgnoreCase("RTG")) return; - - if (event.newBiomeGens[0].getClass().getName().contains("GenLayerEB")) return; - boolean stripRivers = true; // This used to be a config option. Hardcoding until we have a need for the option. - - if (stripRivers) { - try { - event.newBiomeGens = new RiverRemover().riverLess(event.originalBiomeGens); - } catch (ClassCastException ex) { - //throw ex; - // failed attempt because the GenLayers don't end with GenLayerRiverMix - } - } - } - - @SubscribeEvent - public void onWorldLoad(WorldEvent.Load event) { - - if (!event.world.getWorldInfo().getTerrainType().getWorldTypeName().equalsIgnoreCase("RTG")) { - return; - } - - if (event.world.provider.dimensionId == 0) { - - Logger.info("World Seed: %d", event.world.getSeed()); - } - } - - @SubscribeEvent - public void onGetVillageBlockID(BiomeEvent.GetVillageBlockID event) - { - - // Use event.biome, if that's null, fall back to our own copy - if (this.isDesertVillageBiome((event.biome == null) ? this.biome.baseBiome : event.biome)) { - - Block originalBlock = event.original; - - if (originalBlock == Blocks.cobblestone || originalBlock == Blocks.planks || originalBlock == Blocks.log - || originalBlock == Blocks.log2 || originalBlock == Blocks.gravel) { - - event.replacement = Blocks.sandstone; - } else if (originalBlock == Blocks.oak_stairs || originalBlock == Blocks.stone_stairs) { - - event.replacement = Blocks.sandstone_stairs; - } - - // The event has to be cancelled in order to override the original block. - if (event.replacement != null) { - - event.setResult(Result.DENY); - } - } - } - - @SubscribeEvent - public void onGetVillageBlockMeta(BiomeEvent.GetVillageBlockMeta event) - { - boolean replaced = false; - - // Use event.biome, if that's null, fall back to our own copy - if (this.isDesertVillageBiome((event.biome == null) ? this.biome.baseBiome : event.biome)) { - - Block originalBlock = event.original; - - if (originalBlock == Blocks.log || originalBlock == Blocks.log2 || originalBlock == Blocks.cobblestone) { - - event.replacement = 0; - replaced = true; - } - - if (originalBlock == Blocks.planks) { - - event.replacement = 2; - replaced = true; - } - } - // The event has to be cancelled in order to override the original block. - if (replaced) { - - event.setResult(Result.DENY); - } } - @SubscribeEvent - public void preBiomeDecorate(DecorateBiomeEvent.Pre event) + public void registerEventHandlers() { - - //Are we in an RTG world? Do we have RTG's chunk manager? - if (event.world.getWorldInfo().getTerrainType() instanceof WorldTypeRTG && event.world.getWorldChunkManager() instanceof WorldChunkManagerRTG) { - - WorldChunkManagerRTG cmr = (WorldChunkManagerRTG) event.world.getWorldChunkManager(); - this.biome = cmr.getBiomeDataAt(event.chunkX, event.chunkZ); - } + MinecraftForge.EVENT_BUS.register(loadChunkRTG); + MinecraftForge.EVENT_BUS.register(worldLoadRTG); + MinecraftForge.EVENT_BUS.register(worldUnloadRTG); + MinecraftForge.ORE_GEN_BUS.register(generateMinableRTG); + MinecraftForge.TERRAIN_GEN_BUS.register(getVillageBlockRTG); + MinecraftForge.TERRAIN_GEN_BUS.register(preDecorateBiomeRTG); + MinecraftForge.TERRAIN_GEN_BUS.register(initMapGenRTG); + MinecraftForge.TERRAIN_GEN_BUS.register(saplingGrowTreeRTG); + MinecraftForge.TERRAIN_GEN_BUS.register(initBiomeGensRTG); } - @SubscribeEvent - public void onSaplingGrowTree(SaplingGrowTreeEvent event) - { - - // Are RTG saplings enabled? - if (!ConfigRTG.enableRTGSaplings) { - return; - } - - // Are we in an RTG world? Do we have RTG's chunk manager? - if (!(event.world.getWorldInfo().getTerrainType() instanceof WorldTypeRTG) || !(event.world.getWorldChunkManager() instanceof WorldChunkManagerRTG)) { - return; - } - - Random rand = event.rand; - - // Should we generate a vanilla tree instead? - if (rand.nextInt(ConfigRTG.rtgTreeChance) != 0) { - Logger.debug("Skipping RTG tree generation."); - return; - } - - World world = event.world; - int x = event.x; - int y = event.y; - int z = event.z; - - Block saplingBlock = world.getBlock(x, y, z); - byte saplingMeta = (byte) saplingBlock.getDamageValue(world, x, y, z); - - WorldChunkManagerRTG cmr = (WorldChunkManagerRTG) world.getWorldChunkManager(); - //BiomeGenBase bgg = cmr.getBiomeGenAt(x, z); - BiomeGenBase bgg = world.getBiomeGenForCoords(x, z); - RealisticBiomeBase rb = RealisticBiomeBase.getBiome(bgg.biomeID); - ArrayList biomeTrees = rb.rtgTrees; - - Logger.debug("Biome = %s", rb.baseBiome.biomeName); - Logger.debug("Ground Sapling Block = %s", saplingBlock.getLocalizedName()); - Logger.debug("Ground Sapling Meta = %d", saplingMeta); - - if (biomeTrees.size() > 0) { - - // First, let's get all of the trees in this biome that match the sapling on the ground. - ArrayList validTrees = new ArrayList(); - - for (int i = 0; i < biomeTrees.size(); i++) { - - Logger.debug("Biome Tree #%d = %s", i, biomeTrees.get(i).getClass().getName()); - Logger.debug("Biome Tree #%d Sapling Block = %s", i, biomeTrees.get(i).saplingBlock.getClass().getName()); - Logger.debug("Biome Tree #%d Sapling Meta = %d", i, biomeTrees.get(i).saplingMeta); - - if (saplingBlock == biomeTrees.get(i).saplingBlock && saplingMeta == biomeTrees.get(i).saplingMeta) { - validTrees.add(biomeTrees.get(i)); - Logger.debug("Valid tree found!"); - } - } - - // If there are valid trees, then proceed; otherwise, let's get out here. - if (validTrees.size() > 0) { - - // Get a random tree from the list of valid trees. - TreeRTG tree = validTrees.get(rand.nextInt(validTrees.size())); - - Logger.debug("Tree = %s", tree.getClass().getName()); - - // Set the trunk size if min/max values have been set. - if (tree.minTrunkSize > 0 && tree.maxTrunkSize > tree.minTrunkSize) { - tree.trunkSize = RandomUtil.getRandomInt(rand, tree.minTrunkSize, tree.maxTrunkSize); - } - - // Set the crown size if min/max values have been set. - if (tree.minCrownSize > 0 && tree.maxCrownSize > tree.minCrownSize) { - tree.crownSize = RandomUtil.getRandomInt(rand, tree.minCrownSize, tree.maxCrownSize); - } - - /** - * Set the generateFlag to what it needs to be for growing trees from saplings, - * generate the tree, and then set it back to what it was before. - * - * TODO: Does this affect the generation of normal RTG trees? - */ - int oldFlag = tree.generateFlag; - tree.generateFlag = 3; - boolean generated = tree.generate(world, rand, x, y, z); - tree.generateFlag = oldFlag; - - if (generated) { - - // Prevent the original tree from generating. - event.setResult(Result.DENY); - - // Sometimes we have to remove the sapling manually because some trees grow around it, leaving the original sapling. - if (world.getBlock(x, y, z) == saplingBlock) { - world.setBlock(x, y, z, Blocks.air, (byte)0, 2); - } - } - } - else { - - Logger.debug("There are no RTG trees associated with the sapling on the ground. Generating a vanilla tree instead."); - } - } - } - - private boolean isDesertVillageBiome(BiomeGenBase biome) + public void unRegisterEventHandlers() { - if(biome == null) return false; - if ( - BiomeDictionary.isBiomeOfType(biome, Type.HOT) - && - BiomeDictionary.isBiomeOfType(biome, Type.DRY) - && - BiomeDictionary.isBiomeOfType(biome, Type.SANDY) - ) { - return true; - } - - return false; - } - @SubscribeEvent - public void onChunkLoadEvent(ChunkEvent.Load loadEvent) { - Integer dimension = loadEvent.world.provider.dimensionId; - Acceptor acceptor = chunkLoadEvents.get(dimension); - if (acceptor != null) { - acceptor.accept(loadEvent); - } + /** + * The onWorldLoad and onWorldUnload handlers must always be registered. + * + * MinecraftForge.EVENT_BUS.unregister(worldLoadRTG); + * MinecraftForge.EVENT_BUS.unregister(worldUnloadRTG); + */ + + MinecraftForge.EVENT_BUS.unregister(loadChunkRTG); + MinecraftForge.ORE_GEN_BUS.unregister(generateMinableRTG); + MinecraftForge.TERRAIN_GEN_BUS.unregister(getVillageBlockRTG); + MinecraftForge.TERRAIN_GEN_BUS.unregister(preDecorateBiomeRTG); + MinecraftForge.TERRAIN_GEN_BUS.unregister(initMapGenRTG); + MinecraftForge.TERRAIN_GEN_BUS.unregister(saplingGrowTreeRTG); + MinecraftForge.TERRAIN_GEN_BUS.unregister(initBiomeGensRTG); } public void setDimensionChunkLoadEvent(int dimension, Acceptor action) { diff --git a/src/main/java/rtg/event/bus/event/worldevent/LoadChunkRTG.java b/src/main/java/rtg/event/bus/event/worldevent/LoadChunkRTG.java new file mode 100644 index 000000000..debfca760 --- /dev/null +++ b/src/main/java/rtg/event/bus/event/worldevent/LoadChunkRTG.java @@ -0,0 +1,28 @@ +package rtg.event.bus.event.worldevent; + +import java.util.WeakHashMap; + +import net.minecraftforge.event.world.ChunkEvent; +import rtg.util.Acceptor; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; + +public class LoadChunkRTG +{ + + private WeakHashMap> chunkLoadEvents = + new WeakHashMap> (); + + public LoadChunkRTG() + { + + } + + @SubscribeEvent + public void onChunkLoadEvent(ChunkEvent.Load loadEvent) { + Integer dimension = loadEvent.world.provider.dimensionId; + Acceptor acceptor = chunkLoadEvents.get(dimension); + if (acceptor != null) { + acceptor.accept(loadEvent); + } + } +} \ No newline at end of file diff --git a/src/main/java/rtg/event/bus/event/worldevent/WorldLoadRTG.java b/src/main/java/rtg/event/bus/event/worldevent/WorldLoadRTG.java new file mode 100644 index 000000000..b6513ce08 --- /dev/null +++ b/src/main/java/rtg/event/bus/event/worldevent/WorldLoadRTG.java @@ -0,0 +1,38 @@ +package rtg.event.bus.event.worldevent; + +import net.minecraftforge.event.world.WorldEvent; +import rtg.RTG; +import rtg.util.Logger; +import rtg.world.WorldTypeRTG; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; + +public class WorldLoadRTG +{ + + public WorldLoadRTG() + { + + } + + @SubscribeEvent + public void onWorldLoad(WorldEvent.Load event) { + + if (!(event.world.getWorldInfo().getTerrainType() instanceof WorldTypeRTG)) { + + Logger.info("[onWorldLoad] Unregistering RTG's event handlers..."); + RTG.eventMgr.unRegisterEventHandlers(); + Logger.info("[onWorldLoad] RTG's event handlers have been unregistered successfully."); + + return; + } + + Logger.info("[onWorldLoad] Re-registering RTG's event handlers..."); + RTG.eventMgr.registerEventHandlers(); + Logger.info("[onWorldLoad] RTG's event handlers have been re-registered successfully."); + + if (event.world.provider.dimensionId == 0) { + + Logger.info("World Seed: %d", event.world.getSeed()); + } + } +} \ No newline at end of file diff --git a/src/main/java/rtg/event/bus/event/worldevent/WorldUnloadRTG.java b/src/main/java/rtg/event/bus/event/worldevent/WorldUnloadRTG.java new file mode 100644 index 000000000..dcd1a02a2 --- /dev/null +++ b/src/main/java/rtg/event/bus/event/worldevent/WorldUnloadRTG.java @@ -0,0 +1,33 @@ +package rtg.event.bus.event.worldevent; + +import net.minecraftforge.event.world.WorldEvent; +import rtg.RTG; +import rtg.util.Logger; +import rtg.world.WorldTypeRTG; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; + +public class WorldUnloadRTG +{ + + public WorldUnloadRTG() + { + + } + + @SubscribeEvent + public void onWorldUnload(WorldEvent.Unload event) { + + if (event.world.getWorldInfo().getTerrainType() instanceof WorldTypeRTG) { + + Logger.info("[onWorldUnload] Unregistering RTG's event handlers..."); + RTG.eventMgr.unRegisterEventHandlers(); + Logger.info("[onWorldUnload] RTG's event handlers have been unregistered successfully."); + } + else { + + Logger.info("[onWorldUnload] Re-registering RTG's event handlers..."); + RTG.eventMgr.registerEventHandlers(); + Logger.info("[onWorldUnload] RTG's event handlers have been re-registered successfully."); + } + } +} \ No newline at end of file diff --git a/src/main/java/rtg/event/bus/oregen/oregenevent/GenerateMinableRTG.java b/src/main/java/rtg/event/bus/oregen/oregenevent/GenerateMinableRTG.java new file mode 100644 index 000000000..39dc87ff8 --- /dev/null +++ b/src/main/java/rtg/event/bus/oregen/oregenevent/GenerateMinableRTG.java @@ -0,0 +1,73 @@ +package rtg.event.bus.oregen.oregenevent; + +import net.minecraftforge.event.terraingen.OreGenEvent; +import rtg.config.rtg.ConfigRTG; +import cpw.mods.fml.common.eventhandler.Event.Result; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; + +public class GenerateMinableRTG +{ + + public GenerateMinableRTG() + { + + } + + @SubscribeEvent + public void onGenerateMinable(OreGenEvent.GenerateMinable event) { + + switch (event.type) { + + case COAL: + + if (!ConfigRTG.generateOreCoal) { + event.setResult(Result.DENY); + } + + break; + + case IRON: + + if (!ConfigRTG.generateOreIron) { + event.setResult(Result.DENY); + } + + break; + + case GOLD: + + if (!ConfigRTG.generateOreGold) { + event.setResult(Result.DENY); + } + + break; + + case DIAMOND: + + if (!ConfigRTG.generateOreDiamond) { + event.setResult(Result.DENY); + } + + break; + + case REDSTONE: + + if (!ConfigRTG.generateOreRedstone) { + event.setResult(Result.DENY); + } + + break; + + case LAPIS: + + if (!ConfigRTG.generateOreLapis) { + event.setResult(Result.DENY); + } + + break; + + default: + break; + } + } +} \ No newline at end of file diff --git a/src/main/java/rtg/event/bus/terraingen/biomeevent/GetVillageBlockRTG.java b/src/main/java/rtg/event/bus/terraingen/biomeevent/GetVillageBlockRTG.java new file mode 100644 index 000000000..f187a7acf --- /dev/null +++ b/src/main/java/rtg/event/bus/terraingen/biomeevent/GetVillageBlockRTG.java @@ -0,0 +1,92 @@ +package rtg.event.bus.terraingen.biomeevent; + +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraftforge.common.BiomeDictionary; +import net.minecraftforge.common.BiomeDictionary.Type; +import net.minecraftforge.event.terraingen.BiomeEvent; +import rtg.RTG; +import cpw.mods.fml.common.eventhandler.Event.Result; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; + +public class GetVillageBlockRTG +{ + + public GetVillageBlockRTG() + { + + } + + @SubscribeEvent + public void onGetVillageBlockID(BiomeEvent.GetVillageBlockID event) + { + + // Use event.biome, if that's null, fall back to our own copy + if (this.isDesertVillageBiome((event.biome == null) ? RTG.eventMgr.biome.baseBiome : event.biome)) { + + Block originalBlock = event.original; + + if (originalBlock == Blocks.cobblestone || originalBlock == Blocks.planks || originalBlock == Blocks.log + || originalBlock == Blocks.log2 || originalBlock == Blocks.gravel) { + + event.replacement = Blocks.sandstone; + } else if (originalBlock == Blocks.oak_stairs || originalBlock == Blocks.stone_stairs) { + + event.replacement = Blocks.sandstone_stairs; + } + + // The event has to be cancelled in order to override the original block. + if (event.replacement != null) { + + event.setResult(Result.DENY); + } + } + } + + @SubscribeEvent + public void onGetVillageBlockMeta(BiomeEvent.GetVillageBlockMeta event) + { + boolean replaced = false; + + // Use event.biome, if that's null, fall back to our own copy + if (this.isDesertVillageBiome((event.biome == null) ? RTG.eventMgr.biome.baseBiome : event.biome)) { + + Block originalBlock = event.original; + + if (originalBlock == Blocks.log || originalBlock == Blocks.log2 || originalBlock == Blocks.cobblestone) { + + event.replacement = 0; + replaced = true; + } + + if (originalBlock == Blocks.planks) { + + event.replacement = 2; + replaced = true; + } + } + + // The event has to be cancelled in order to override the original block. + if (replaced) { + + event.setResult(Result.DENY); + } + } + + private boolean isDesertVillageBiome(BiomeGenBase biome) + { + if(biome == null) return false; + if ( + BiomeDictionary.isBiomeOfType(biome, Type.HOT) + && + BiomeDictionary.isBiomeOfType(biome, Type.DRY) + && + BiomeDictionary.isBiomeOfType(biome, Type.SANDY) + ) { + return true; + } + + return false; + } +} \ No newline at end of file diff --git a/src/main/java/rtg/event/bus/terraingen/decoratebiomeevent/PreDecorateBiomeRTG.java b/src/main/java/rtg/event/bus/terraingen/decoratebiomeevent/PreDecorateBiomeRTG.java new file mode 100644 index 000000000..d39da652d --- /dev/null +++ b/src/main/java/rtg/event/bus/terraingen/decoratebiomeevent/PreDecorateBiomeRTG.java @@ -0,0 +1,28 @@ +package rtg.event.bus.terraingen.decoratebiomeevent; + +import net.minecraftforge.event.terraingen.DecorateBiomeEvent; +import rtg.RTG; +import rtg.world.WorldTypeRTG; +import rtg.world.biome.WorldChunkManagerRTG; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; + +public class PreDecorateBiomeRTG +{ + + public PreDecorateBiomeRTG() + { + + } + + @SubscribeEvent + public void preBiomeDecorate(DecorateBiomeEvent.Pre event) + { + + //Are we in an RTG world? Do we have RTG's chunk manager? + if (event.world.getWorldInfo().getTerrainType() instanceof WorldTypeRTG && event.world.getWorldChunkManager() instanceof WorldChunkManagerRTG) { + + WorldChunkManagerRTG cmr = (WorldChunkManagerRTG) event.world.getWorldChunkManager(); + RTG.eventMgr.biome = cmr.getBiomeDataAt(event.chunkX, event.chunkZ); + } + } +} \ No newline at end of file diff --git a/src/main/java/rtg/event/bus/terraingen/initmapgenevent/InitMapGenRTG.java b/src/main/java/rtg/event/bus/terraingen/initmapgenevent/InitMapGenRTG.java new file mode 100644 index 000000000..7bb2f4061 --- /dev/null +++ b/src/main/java/rtg/event/bus/terraingen/initmapgenevent/InitMapGenRTG.java @@ -0,0 +1,53 @@ +package rtg.event.bus.terraingen.initmapgenevent; + +import net.minecraftforge.event.terraingen.InitMapGenEvent; +import rtg.config.rtg.ConfigRTG; +import rtg.util.Logger; +import rtg.world.gen.MapGenCavesRTG; +import rtg.world.gen.MapGenRavineRTG; +import rtg.world.gen.structure.MapGenScatteredFeatureRTG; +import rtg.world.gen.structure.MapGenVillageRTG; +import cpw.mods.fml.common.eventhandler.EventPriority; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; + +public class InitMapGenRTG +{ + + public InitMapGenRTG() + { + + } + + @SubscribeEvent(priority = EventPriority.LOW) + public void onInitMapGen(InitMapGenEvent event) { + + Logger.debug("event type = %s", event.type.toString()); + Logger.debug("event originalGen = %s", event.originalGen.toString()); + + if (event.type == InitMapGenEvent.EventType.SCATTERED_FEATURE) { + event.newGen = new MapGenScatteredFeatureRTG(); + } + else if (event.type == InitMapGenEvent.EventType.VILLAGE) { + + if (ConfigRTG.enableVillageModifications) { + event.newGen = new MapGenVillageRTG(); + } + } + else if (event.type == InitMapGenEvent.EventType.CAVE) { + + if (ConfigRTG.enableCaveModifications) { + + event.newGen = new MapGenCavesRTG(); + } + } + else if (event.type == InitMapGenEvent.EventType.RAVINE) { + + if (ConfigRTG.enableRavineModifications) { + + event.newGen = new MapGenRavineRTG(); + } + } + + Logger.debug("event newGen = %s", event.newGen.toString()); + } +} \ No newline at end of file diff --git a/src/main/java/rtg/event/bus/terraingen/saplinggrowtreeevent/SaplingGrowTreeRTG.java b/src/main/java/rtg/event/bus/terraingen/saplinggrowtreeevent/SaplingGrowTreeRTG.java new file mode 100644 index 000000000..13137f3ea --- /dev/null +++ b/src/main/java/rtg/event/bus/terraingen/saplinggrowtreeevent/SaplingGrowTreeRTG.java @@ -0,0 +1,132 @@ +package rtg.event.bus.terraingen.saplinggrowtreeevent; + +import java.util.ArrayList; +import java.util.Random; + +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraftforge.event.terraingen.SaplingGrowTreeEvent; +import rtg.config.rtg.ConfigRTG; +import rtg.util.Logger; +import rtg.util.RandomUtil; +import rtg.world.WorldTypeRTG; +import rtg.world.biome.WorldChunkManagerRTG; +import rtg.world.biome.realistic.RealisticBiomeBase; +import rtg.world.gen.feature.tree.rtg.TreeRTG; +import cpw.mods.fml.common.eventhandler.Event.Result; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; + +public class SaplingGrowTreeRTG +{ + + public SaplingGrowTreeRTG() + { + + } + + @SubscribeEvent + public void onSaplingGrowTree(SaplingGrowTreeEvent event) + { + + // Are RTG saplings enabled? + if (!ConfigRTG.enableRTGSaplings) { + return; + } + + // Are we in an RTG world? Do we have RTG's chunk manager? + if (!(event.world.getWorldInfo().getTerrainType() instanceof WorldTypeRTG) || !(event.world.getWorldChunkManager() instanceof WorldChunkManagerRTG)) { + return; + } + + Random rand = event.rand; + + // Should we generate a vanilla tree instead? + if (rand.nextInt(ConfigRTG.rtgTreeChance) != 0) { + Logger.debug("Skipping RTG tree generation."); + return; + } + + World world = event.world; + int x = event.x; + int y = event.y; + int z = event.z; + + Block saplingBlock = world.getBlock(x, y, z); + byte saplingMeta = (byte) saplingBlock.getDamageValue(world, x, y, z); + + WorldChunkManagerRTG cmr = (WorldChunkManagerRTG) world.getWorldChunkManager(); + //BiomeGenBase bgg = cmr.getBiomeGenAt(x, z); + BiomeGenBase bgg = world.getBiomeGenForCoords(x, z); + RealisticBiomeBase rb = RealisticBiomeBase.getBiome(bgg.biomeID); + ArrayList biomeTrees = rb.rtgTrees; + + Logger.debug("Biome = %s", rb.baseBiome.biomeName); + Logger.debug("Ground Sapling Block = %s", saplingBlock.getLocalizedName()); + Logger.debug("Ground Sapling Meta = %d", saplingMeta); + + if (biomeTrees.size() > 0) { + + // First, let's get all of the trees in this biome that match the sapling on the ground. + ArrayList validTrees = new ArrayList(); + + for (int i = 0; i < biomeTrees.size(); i++) { + + Logger.debug("Biome Tree #%d = %s", i, biomeTrees.get(i).getClass().getName()); + Logger.debug("Biome Tree #%d Sapling Block = %s", i, biomeTrees.get(i).saplingBlock.getClass().getName()); + Logger.debug("Biome Tree #%d Sapling Meta = %d", i, biomeTrees.get(i).saplingMeta); + + if (saplingBlock == biomeTrees.get(i).saplingBlock && saplingMeta == biomeTrees.get(i).saplingMeta) { + validTrees.add(biomeTrees.get(i)); + Logger.debug("Valid tree found!"); + } + } + + // If there are valid trees, then proceed; otherwise, let's get out here. + if (validTrees.size() > 0) { + + // Get a random tree from the list of valid trees. + TreeRTG tree = validTrees.get(rand.nextInt(validTrees.size())); + + Logger.debug("Tree = %s", tree.getClass().getName()); + + // Set the trunk size if min/max values have been set. + if (tree.minTrunkSize > 0 && tree.maxTrunkSize > tree.minTrunkSize) { + tree.trunkSize = RandomUtil.getRandomInt(rand, tree.minTrunkSize, tree.maxTrunkSize); + } + + // Set the crown size if min/max values have been set. + if (tree.minCrownSize > 0 && tree.maxCrownSize > tree.minCrownSize) { + tree.crownSize = RandomUtil.getRandomInt(rand, tree.minCrownSize, tree.maxCrownSize); + } + + /** + * Set the generateFlag to what it needs to be for growing trees from saplings, + * generate the tree, and then set it back to what it was before. + * + * TODO: Does this affect the generation of normal RTG trees? + */ + int oldFlag = tree.generateFlag; + tree.generateFlag = 3; + boolean generated = tree.generate(world, rand, x, y, z); + tree.generateFlag = oldFlag; + + if (generated) { + + // Prevent the original tree from generating. + event.setResult(Result.DENY); + + // Sometimes we have to remove the sapling manually because some trees grow around it, leaving the original sapling. + if (world.getBlock(x, y, z) == saplingBlock) { + world.setBlock(x, y, z, Blocks.air, (byte)0, 2); + } + } + } + else { + + Logger.debug("There are no RTG trees associated with the sapling on the ground. Generating a vanilla tree instead."); + } + } + } +} \ No newline at end of file diff --git a/src/main/java/rtg/event/bus/terraingen/worldtypeevent/InitBiomeGensRTG.java b/src/main/java/rtg/event/bus/terraingen/worldtypeevent/InitBiomeGensRTG.java new file mode 100644 index 000000000..932491580 --- /dev/null +++ b/src/main/java/rtg/event/bus/terraingen/worldtypeevent/InitBiomeGensRTG.java @@ -0,0 +1,33 @@ +package rtg.event.bus.terraingen.worldtypeevent; + +import net.minecraftforge.event.terraingen.WorldTypeEvent; +import rtg.world.gen.genlayer.RiverRemover; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; + +public class InitBiomeGensRTG +{ + + public InitBiomeGensRTG() + { + + } + + @SubscribeEvent + public void onBiomeGenInit(WorldTypeEvent.InitBiomeGens event) { + + // only handle RTG world type + if (!event.worldType.getWorldTypeName().equalsIgnoreCase("RTG")) return; + + if (event.newBiomeGens[0].getClass().getName().contains("GenLayerEB")) return; + boolean stripRivers = true; // This used to be a config option. Hardcoding until we have a need for the option. + + if (stripRivers) { + try { + event.newBiomeGens = new RiverRemover().riverLess(event.originalBiomeGens); + } catch (ClassCastException ex) { + //throw ex; + // failed attempt because the GenLayers don't end with GenLayerRiverMix + } + } + } +} \ No newline at end of file From 1e6353a7027d0cb47ff43d9eb0d200f74b76cd4c Mon Sep 17 00:00:00 2001 From: WhichOnesPink Date: Sat, 9 Jul 2016 21:53:31 +0100 Subject: [PATCH 03/22] Event handlers are now inner classes within EventManagerRTG. Doing this has also resolved the decoration issue, but further testing still required. --- src/main/java/rtg/RTG.java | 7 +- src/main/java/rtg/event/EventManagerRTG.java | 410 +++++++++++++++++- .../bus/event/worldevent/LoadChunkRTG.java | 28 -- .../bus/event/worldevent/WorldLoadRTG.java | 38 -- .../bus/event/worldevent/WorldUnloadRTG.java | 33 -- .../oregenevent/GenerateMinableRTG.java | 73 ---- .../biomeevent/GetVillageBlockRTG.java | 92 ---- .../PreDecorateBiomeRTG.java | 28 -- .../initmapgenevent/InitMapGenRTG.java | 53 --- .../SaplingGrowTreeRTG.java | 132 ------ .../worldtypeevent/InitBiomeGensRTG.java | 33 -- 11 files changed, 395 insertions(+), 532 deletions(-) delete mode 100644 src/main/java/rtg/event/bus/event/worldevent/LoadChunkRTG.java delete mode 100644 src/main/java/rtg/event/bus/event/worldevent/WorldLoadRTG.java delete mode 100644 src/main/java/rtg/event/bus/event/worldevent/WorldUnloadRTG.java delete mode 100644 src/main/java/rtg/event/bus/oregen/oregenevent/GenerateMinableRTG.java delete mode 100644 src/main/java/rtg/event/bus/terraingen/biomeevent/GetVillageBlockRTG.java delete mode 100644 src/main/java/rtg/event/bus/terraingen/decoratebiomeevent/PreDecorateBiomeRTG.java delete mode 100644 src/main/java/rtg/event/bus/terraingen/initmapgenevent/InitMapGenRTG.java delete mode 100644 src/main/java/rtg/event/bus/terraingen/saplinggrowtreeevent/SaplingGrowTreeRTG.java delete mode 100644 src/main/java/rtg/event/bus/terraingen/worldtypeevent/InitBiomeGensRTG.java diff --git a/src/main/java/rtg/RTG.java b/src/main/java/rtg/RTG.java index a6d7b6680..ede800486 100755 --- a/src/main/java/rtg/RTG.java +++ b/src/main/java/rtg/RTG.java @@ -9,6 +9,7 @@ import rtg.config.ConfigManager; import rtg.event.EventManagerRTG; import rtg.reference.ModInfo; +import rtg.util.Logger; import rtg.util.RealisticBiomePresenceTester; import rtg.world.WorldTypeRTG; import rtg.world.biome.realistic.abyssalcraft.RealisticBiomeACBase; @@ -65,8 +66,10 @@ public void fmlLifeCycleEvent(FMLPreInitializationEvent event) MapGenStructureIO.registerStructure(MapGenVillageRTG.Start.class, "rtg_MapGenVillageRTG"); eventMgr = new EventManagerRTG(); - eventMgr.registerEventHandlers(); - + Logger.info("[FMLPreInitializationEvent] Registering RTG's event handlers..."); + eventMgr.registerEventHandlers(); + Logger.info("[FMLPreInitializationEvent] RTG's event handlers have been registered successfully."); + MinecraftForge.EVENT_BUS.post(new BiomeConfigEvent.Pre()); // This MUST get called before the config is initialised. diff --git a/src/main/java/rtg/event/EventManagerRTG.java b/src/main/java/rtg/event/EventManagerRTG.java index 57a523bf1..130457b9c 100755 --- a/src/main/java/rtg/event/EventManagerRTG.java +++ b/src/main/java/rtg/event/EventManagerRTG.java @@ -1,35 +1,56 @@ package rtg.event; +import java.util.ArrayList; +import java.util.Random; import java.util.WeakHashMap; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; +import net.minecraftforge.common.BiomeDictionary; +import net.minecraftforge.common.BiomeDictionary.Type; import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.terraingen.BiomeEvent; +import net.minecraftforge.event.terraingen.DecorateBiomeEvent; +import net.minecraftforge.event.terraingen.InitMapGenEvent; +import net.minecraftforge.event.terraingen.OreGenEvent; +import net.minecraftforge.event.terraingen.SaplingGrowTreeEvent; +import net.minecraftforge.event.terraingen.WorldTypeEvent; import net.minecraftforge.event.world.ChunkEvent; -import rtg.event.bus.event.worldevent.LoadChunkRTG; -import rtg.event.bus.event.worldevent.WorldLoadRTG; -import rtg.event.bus.event.worldevent.WorldUnloadRTG; -import rtg.event.bus.oregen.oregenevent.GenerateMinableRTG; -import rtg.event.bus.terraingen.biomeevent.GetVillageBlockRTG; -import rtg.event.bus.terraingen.decoratebiomeevent.PreDecorateBiomeRTG; -import rtg.event.bus.terraingen.initmapgenevent.InitMapGenRTG; -import rtg.event.bus.terraingen.saplinggrowtreeevent.SaplingGrowTreeRTG; -import rtg.event.bus.terraingen.worldtypeevent.InitBiomeGensRTG; +import net.minecraftforge.event.world.WorldEvent; +import rtg.RTG; +import rtg.config.rtg.ConfigRTG; import rtg.util.Acceptor; +import rtg.util.Logger; +import rtg.util.RandomUtil; +import rtg.world.WorldTypeRTG; +import rtg.world.biome.WorldChunkManagerRTG; import rtg.world.biome.realistic.RealisticBiomeBase; +import rtg.world.gen.MapGenCavesRTG; +import rtg.world.gen.MapGenRavineRTG; +import rtg.world.gen.feature.tree.rtg.TreeRTG; +import rtg.world.gen.genlayer.RiverRemover; +import rtg.world.gen.structure.MapGenScatteredFeatureRTG; +import rtg.world.gen.structure.MapGenVillageRTG; +import cpw.mods.fml.common.eventhandler.Event.Result; +import cpw.mods.fml.common.eventhandler.EventPriority; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; public class EventManagerRTG { - public static LoadChunkRTG loadChunkRTG = new LoadChunkRTG(); - public static WorldLoadRTG worldLoadRTG = new WorldLoadRTG(); - public static WorldUnloadRTG worldUnloadRTG = new WorldUnloadRTG(); - public static GenerateMinableRTG generateMinableRTG = new GenerateMinableRTG(); - public static GetVillageBlockRTG getVillageBlockRTG = new GetVillageBlockRTG(); - public static PreDecorateBiomeRTG preDecorateBiomeRTG = new PreDecorateBiomeRTG(); - public static InitMapGenRTG initMapGenRTG = new InitMapGenRTG(); - public static SaplingGrowTreeRTG saplingGrowTreeRTG = new SaplingGrowTreeRTG(); - public static InitBiomeGensRTG initBiomeGensRTG = new InitBiomeGensRTG(); + public EventManagerRTG.LoadChunkRTG loadChunkRTG = new EventManagerRTG.LoadChunkRTG(); + public EventManagerRTG.WorldLoadRTG worldLoadRTG = new EventManagerRTG.WorldLoadRTG(); + public EventManagerRTG.WorldUnloadRTG worldUnloadRTG = new EventManagerRTG.WorldUnloadRTG(); + public EventManagerRTG.GenerateMinableRTG generateMinableRTG = new EventManagerRTG.GenerateMinableRTG(); + public EventManagerRTG.GetVillageBlockRTG getVillageBlockRTG = new EventManagerRTG.GetVillageBlockRTG(); + public EventManagerRTG.PreDecorateBiomeRTG preDecorateBiomeRTG = new EventManagerRTG.PreDecorateBiomeRTG(); + public EventManagerRTG.InitMapGenRTG initMapGenRTG = new EventManagerRTG.InitMapGenRTG(); + public EventManagerRTG.SaplingGrowTreeRTG saplingGrowTreeRTG = new EventManagerRTG.SaplingGrowTreeRTG(); + public EventManagerRTG.InitBiomeGensRTG initBiomeGensRTG = new EventManagerRTG.InitBiomeGensRTG(); - public RealisticBiomeBase biome = null; + private RealisticBiomeBase biome = null; private WeakHashMap> chunkLoadEvents = new WeakHashMap> (); @@ -74,4 +95,353 @@ public void unRegisterEventHandlers() public void setDimensionChunkLoadEvent(int dimension, Acceptor action) { chunkLoadEvents.put(dimension, action); } -} \ No newline at end of file + + public class GenerateMinableRTG + { + @SubscribeEvent + public void onGenerateMinable(OreGenEvent.GenerateMinable event) { + + switch (event.type) { + + case COAL: + if (!ConfigRTG.generateOreCoal) { event.setResult(Result.DENY); } + return; + + case IRON: + if (!ConfigRTG.generateOreIron) { event.setResult(Result.DENY); } + return; + + case REDSTONE: + if (!ConfigRTG.generateOreRedstone) { event.setResult(Result.DENY); } + return; + + case GOLD: + if (!ConfigRTG.generateOreGold) { event.setResult(Result.DENY); } + return; + + case LAPIS: + if (!ConfigRTG.generateOreLapis) { event.setResult(Result.DENY); } + return; + + case DIAMOND: + if (!ConfigRTG.generateOreDiamond) { event.setResult(Result.DENY); } + return; + + default: + return; + } + } + } + + public class GetVillageBlockRTG + { + @SubscribeEvent + public void onGetVillageBlockID(BiomeEvent.GetVillageBlockID event) + { + + // Use event.biome, if that's null, fall back to our own copy + if (this.isDesertVillageBiome((event.biome == null) ? RTG.eventMgr.biome.baseBiome : event.biome)) { + + Block originalBlock = event.original; + + if (originalBlock == Blocks.cobblestone || originalBlock == Blocks.planks || originalBlock == Blocks.log + || originalBlock == Blocks.log2 || originalBlock == Blocks.gravel) { + + event.replacement = Blocks.sandstone; + } else if (originalBlock == Blocks.oak_stairs || originalBlock == Blocks.stone_stairs) { + + event.replacement = Blocks.sandstone_stairs; + } + + // The event has to be cancelled in order to override the original block. + if (event.replacement != null) { + + event.setResult(Result.DENY); + } + } + } + + @SubscribeEvent + public void onGetVillageBlockMeta(BiomeEvent.GetVillageBlockMeta event) + { + boolean replaced = false; + + // Use event.biome, if that's null, fall back to our own copy + if (this.isDesertVillageBiome((event.biome == null) ? RTG.eventMgr.biome.baseBiome : event.biome)) { + + Block originalBlock = event.original; + + if (originalBlock == Blocks.log || originalBlock == Blocks.log2 || originalBlock == Blocks.cobblestone) { + + event.replacement = 0; + replaced = true; + } + + if (originalBlock == Blocks.planks) { + + event.replacement = 2; + replaced = true; + } + } + + // The event has to be cancelled in order to override the original block. + if (replaced) { + + event.setResult(Result.DENY); + } + } + + private boolean isDesertVillageBiome(BiomeGenBase biome) + { + if(biome == null) return false; + if ( + BiomeDictionary.isBiomeOfType(biome, Type.HOT) + && + BiomeDictionary.isBiomeOfType(biome, Type.DRY) + && + BiomeDictionary.isBiomeOfType(biome, Type.SANDY) + ) { + return true; + } + + return false; + } + } + + public class InitBiomeGensRTG + { + @SubscribeEvent + public void onBiomeGenInit(WorldTypeEvent.InitBiomeGens event) { + + // only handle RTG world type + if (!event.worldType.getWorldTypeName().equalsIgnoreCase("RTG")) return; + + if (event.newBiomeGens[0].getClass().getName().contains("GenLayerEB")) return; + boolean stripRivers = true; // This used to be a config option. Hardcoding until we have a need for the option. + + if (stripRivers) { + try { + event.newBiomeGens = new RiverRemover().riverLess(event.originalBiomeGens); + } catch (ClassCastException ex) { + //throw ex; + // failed attempt because the GenLayers don't end with GenLayerRiverMix + } + } + } + } + + public class InitMapGenRTG + { + @SubscribeEvent(priority = EventPriority.LOW) + public void onInitMapGen(InitMapGenEvent event) { + + Logger.debug("event type = %s", event.type.toString()); + Logger.debug("event originalGen = %s", event.originalGen.toString()); + + if (event.type == InitMapGenEvent.EventType.SCATTERED_FEATURE) { + event.newGen = new MapGenScatteredFeatureRTG(); + } + else if (event.type == InitMapGenEvent.EventType.VILLAGE) { + + if (ConfigRTG.enableVillageModifications) { + event.newGen = new MapGenVillageRTG(); + } + } + else if (event.type == InitMapGenEvent.EventType.CAVE) { + + if (ConfigRTG.enableCaveModifications) { + + event.newGen = new MapGenCavesRTG(); + } + } + else if (event.type == InitMapGenEvent.EventType.RAVINE) { + + if (ConfigRTG.enableRavineModifications) { + + event.newGen = new MapGenRavineRTG(); + } + } + + Logger.debug("event newGen = %s", event.newGen.toString()); + } + } + + public class LoadChunkRTG + { + @SubscribeEvent + public void onChunkLoadEvent(ChunkEvent.Load loadEvent) { + Integer dimension = loadEvent.world.provider.dimensionId; + Acceptor acceptor = chunkLoadEvents.get(dimension); + if (acceptor != null) { + acceptor.accept(loadEvent); + } + } + } + + public class PreDecorateBiomeRTG + { + @SubscribeEvent + public void preBiomeDecorate(DecorateBiomeEvent.Pre event) + { + + //Are we in an RTG world? Do we have RTG's chunk manager? + if (event.world.getWorldInfo().getTerrainType() instanceof WorldTypeRTG && event.world.getWorldChunkManager() instanceof WorldChunkManagerRTG) { + + WorldChunkManagerRTG cmr = (WorldChunkManagerRTG) event.world.getWorldChunkManager(); + RTG.eventMgr.biome = cmr.getBiomeDataAt(event.chunkX, event.chunkZ); + } + } + } + + public class SaplingGrowTreeRTG + { + @SubscribeEvent + public void onSaplingGrowTree(SaplingGrowTreeEvent event) + { + + // Are RTG saplings enabled? + if (!ConfigRTG.enableRTGSaplings) { + return; + } + + // Are we in an RTG world? Do we have RTG's chunk manager? + if (!(event.world.getWorldInfo().getTerrainType() instanceof WorldTypeRTG) || !(event.world.getWorldChunkManager() instanceof WorldChunkManagerRTG)) { + return; + } + + Random rand = event.rand; + + // Should we generate a vanilla tree instead? + if (rand.nextInt(ConfigRTG.rtgTreeChance) != 0) { + Logger.debug("Skipping RTG tree generation."); + return; + } + + World world = event.world; + int x = event.x; + int y = event.y; + int z = event.z; + + Block saplingBlock = world.getBlock(x, y, z); + byte saplingMeta = (byte) saplingBlock.getDamageValue(world, x, y, z); + + WorldChunkManagerRTG cmr = (WorldChunkManagerRTG) world.getWorldChunkManager(); + //BiomeGenBase bgg = cmr.getBiomeGenAt(x, z); + BiomeGenBase bgg = world.getBiomeGenForCoords(x, z); + RealisticBiomeBase rb = RealisticBiomeBase.getBiome(bgg.biomeID); + ArrayList biomeTrees = rb.rtgTrees; + + Logger.debug("Biome = %s", rb.baseBiome.biomeName); + Logger.debug("Ground Sapling Block = %s", saplingBlock.getLocalizedName()); + Logger.debug("Ground Sapling Meta = %d", saplingMeta); + + if (biomeTrees.size() > 0) { + + // First, let's get all of the trees in this biome that match the sapling on the ground. + ArrayList validTrees = new ArrayList(); + + for (int i = 0; i < biomeTrees.size(); i++) { + + Logger.debug("Biome Tree #%d = %s", i, biomeTrees.get(i).getClass().getName()); + Logger.debug("Biome Tree #%d Sapling Block = %s", i, biomeTrees.get(i).saplingBlock.getClass().getName()); + Logger.debug("Biome Tree #%d Sapling Meta = %d", i, biomeTrees.get(i).saplingMeta); + + if (saplingBlock == biomeTrees.get(i).saplingBlock && saplingMeta == biomeTrees.get(i).saplingMeta) { + validTrees.add(biomeTrees.get(i)); + Logger.debug("Valid tree found!"); + } + } + + // If there are valid trees, then proceed; otherwise, let's get out here. + if (validTrees.size() > 0) { + + // Get a random tree from the list of valid trees. + TreeRTG tree = validTrees.get(rand.nextInt(validTrees.size())); + + Logger.debug("Tree = %s", tree.getClass().getName()); + + // Set the trunk size if min/max values have been set. + if (tree.minTrunkSize > 0 && tree.maxTrunkSize > tree.minTrunkSize) { + tree.trunkSize = RandomUtil.getRandomInt(rand, tree.minTrunkSize, tree.maxTrunkSize); + } + + // Set the crown size if min/max values have been set. + if (tree.minCrownSize > 0 && tree.maxCrownSize > tree.minCrownSize) { + tree.crownSize = RandomUtil.getRandomInt(rand, tree.minCrownSize, tree.maxCrownSize); + } + + /** + * Set the generateFlag to what it needs to be for growing trees from saplings, + * generate the tree, and then set it back to what it was before. + * + * TODO: Does this affect the generation of normal RTG trees? + */ + int oldFlag = tree.generateFlag; + tree.generateFlag = 3; + boolean generated = tree.generate(world, rand, x, y, z); + tree.generateFlag = oldFlag; + + if (generated) { + + // Prevent the original tree from generating. + event.setResult(Result.DENY); + + // Sometimes we have to remove the sapling manually because some trees grow around it, leaving the original sapling. + if (world.getBlock(x, y, z) == saplingBlock) { + world.setBlock(x, y, z, Blocks.air, (byte)0, 2); + } + } + } + else { + + Logger.debug("There are no RTG trees associated with the sapling on the ground. Generating a vanilla tree instead."); + } + } + } + } + + public class WorldLoadRTG + { + @SubscribeEvent + public void onWorldLoad(WorldEvent.Load event) { + + if (!(event.world.getWorldInfo().getTerrainType() instanceof WorldTypeRTG)) { + + Logger.info("[onWorldLoad] Unregistering RTG's event handlers..."); + RTG.eventMgr.unRegisterEventHandlers(); + Logger.info("[onWorldLoad] RTG's event handlers have been unregistered successfully."); + + return; + } + + Logger.info("[onWorldLoad] Re-registering RTG's event handlers..."); + RTG.eventMgr.registerEventHandlers(); + Logger.info("[onWorldLoad] RTG's event handlers have been re-registered successfully."); + + if (event.world.provider.dimensionId == 0) { + + Logger.info("World Seed: %d", event.world.getSeed()); + } + } + } + + public class WorldUnloadRTG + { + @SubscribeEvent + public void onWorldUnload(WorldEvent.Unload event) { + + if (event.world.getWorldInfo().getTerrainType() instanceof WorldTypeRTG) { + + Logger.info("[onWorldUnload] Unregistering RTG's event handlers..."); + RTG.eventMgr.unRegisterEventHandlers(); + Logger.info("[onWorldUnload] RTG's event handlers have been unregistered successfully."); + } + else { + + Logger.info("[onWorldUnload] Re-registering RTG's event handlers..."); + RTG.eventMgr.registerEventHandlers(); + Logger.info("[onWorldUnload] RTG's event handlers have been re-registered successfully."); + } + } + } +} diff --git a/src/main/java/rtg/event/bus/event/worldevent/LoadChunkRTG.java b/src/main/java/rtg/event/bus/event/worldevent/LoadChunkRTG.java deleted file mode 100644 index debfca760..000000000 --- a/src/main/java/rtg/event/bus/event/worldevent/LoadChunkRTG.java +++ /dev/null @@ -1,28 +0,0 @@ -package rtg.event.bus.event.worldevent; - -import java.util.WeakHashMap; - -import net.minecraftforge.event.world.ChunkEvent; -import rtg.util.Acceptor; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; - -public class LoadChunkRTG -{ - - private WeakHashMap> chunkLoadEvents = - new WeakHashMap> (); - - public LoadChunkRTG() - { - - } - - @SubscribeEvent - public void onChunkLoadEvent(ChunkEvent.Load loadEvent) { - Integer dimension = loadEvent.world.provider.dimensionId; - Acceptor acceptor = chunkLoadEvents.get(dimension); - if (acceptor != null) { - acceptor.accept(loadEvent); - } - } -} \ No newline at end of file diff --git a/src/main/java/rtg/event/bus/event/worldevent/WorldLoadRTG.java b/src/main/java/rtg/event/bus/event/worldevent/WorldLoadRTG.java deleted file mode 100644 index b6513ce08..000000000 --- a/src/main/java/rtg/event/bus/event/worldevent/WorldLoadRTG.java +++ /dev/null @@ -1,38 +0,0 @@ -package rtg.event.bus.event.worldevent; - -import net.minecraftforge.event.world.WorldEvent; -import rtg.RTG; -import rtg.util.Logger; -import rtg.world.WorldTypeRTG; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; - -public class WorldLoadRTG -{ - - public WorldLoadRTG() - { - - } - - @SubscribeEvent - public void onWorldLoad(WorldEvent.Load event) { - - if (!(event.world.getWorldInfo().getTerrainType() instanceof WorldTypeRTG)) { - - Logger.info("[onWorldLoad] Unregistering RTG's event handlers..."); - RTG.eventMgr.unRegisterEventHandlers(); - Logger.info("[onWorldLoad] RTG's event handlers have been unregistered successfully."); - - return; - } - - Logger.info("[onWorldLoad] Re-registering RTG's event handlers..."); - RTG.eventMgr.registerEventHandlers(); - Logger.info("[onWorldLoad] RTG's event handlers have been re-registered successfully."); - - if (event.world.provider.dimensionId == 0) { - - Logger.info("World Seed: %d", event.world.getSeed()); - } - } -} \ No newline at end of file diff --git a/src/main/java/rtg/event/bus/event/worldevent/WorldUnloadRTG.java b/src/main/java/rtg/event/bus/event/worldevent/WorldUnloadRTG.java deleted file mode 100644 index dcd1a02a2..000000000 --- a/src/main/java/rtg/event/bus/event/worldevent/WorldUnloadRTG.java +++ /dev/null @@ -1,33 +0,0 @@ -package rtg.event.bus.event.worldevent; - -import net.minecraftforge.event.world.WorldEvent; -import rtg.RTG; -import rtg.util.Logger; -import rtg.world.WorldTypeRTG; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; - -public class WorldUnloadRTG -{ - - public WorldUnloadRTG() - { - - } - - @SubscribeEvent - public void onWorldUnload(WorldEvent.Unload event) { - - if (event.world.getWorldInfo().getTerrainType() instanceof WorldTypeRTG) { - - Logger.info("[onWorldUnload] Unregistering RTG's event handlers..."); - RTG.eventMgr.unRegisterEventHandlers(); - Logger.info("[onWorldUnload] RTG's event handlers have been unregistered successfully."); - } - else { - - Logger.info("[onWorldUnload] Re-registering RTG's event handlers..."); - RTG.eventMgr.registerEventHandlers(); - Logger.info("[onWorldUnload] RTG's event handlers have been re-registered successfully."); - } - } -} \ No newline at end of file diff --git a/src/main/java/rtg/event/bus/oregen/oregenevent/GenerateMinableRTG.java b/src/main/java/rtg/event/bus/oregen/oregenevent/GenerateMinableRTG.java deleted file mode 100644 index 39dc87ff8..000000000 --- a/src/main/java/rtg/event/bus/oregen/oregenevent/GenerateMinableRTG.java +++ /dev/null @@ -1,73 +0,0 @@ -package rtg.event.bus.oregen.oregenevent; - -import net.minecraftforge.event.terraingen.OreGenEvent; -import rtg.config.rtg.ConfigRTG; -import cpw.mods.fml.common.eventhandler.Event.Result; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; - -public class GenerateMinableRTG -{ - - public GenerateMinableRTG() - { - - } - - @SubscribeEvent - public void onGenerateMinable(OreGenEvent.GenerateMinable event) { - - switch (event.type) { - - case COAL: - - if (!ConfigRTG.generateOreCoal) { - event.setResult(Result.DENY); - } - - break; - - case IRON: - - if (!ConfigRTG.generateOreIron) { - event.setResult(Result.DENY); - } - - break; - - case GOLD: - - if (!ConfigRTG.generateOreGold) { - event.setResult(Result.DENY); - } - - break; - - case DIAMOND: - - if (!ConfigRTG.generateOreDiamond) { - event.setResult(Result.DENY); - } - - break; - - case REDSTONE: - - if (!ConfigRTG.generateOreRedstone) { - event.setResult(Result.DENY); - } - - break; - - case LAPIS: - - if (!ConfigRTG.generateOreLapis) { - event.setResult(Result.DENY); - } - - break; - - default: - break; - } - } -} \ No newline at end of file diff --git a/src/main/java/rtg/event/bus/terraingen/biomeevent/GetVillageBlockRTG.java b/src/main/java/rtg/event/bus/terraingen/biomeevent/GetVillageBlockRTG.java deleted file mode 100644 index f187a7acf..000000000 --- a/src/main/java/rtg/event/bus/terraingen/biomeevent/GetVillageBlockRTG.java +++ /dev/null @@ -1,92 +0,0 @@ -package rtg.event.bus.terraingen.biomeevent; - -import net.minecraft.block.Block; -import net.minecraft.init.Blocks; -import net.minecraft.world.biome.BiomeGenBase; -import net.minecraftforge.common.BiomeDictionary; -import net.minecraftforge.common.BiomeDictionary.Type; -import net.minecraftforge.event.terraingen.BiomeEvent; -import rtg.RTG; -import cpw.mods.fml.common.eventhandler.Event.Result; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; - -public class GetVillageBlockRTG -{ - - public GetVillageBlockRTG() - { - - } - - @SubscribeEvent - public void onGetVillageBlockID(BiomeEvent.GetVillageBlockID event) - { - - // Use event.biome, if that's null, fall back to our own copy - if (this.isDesertVillageBiome((event.biome == null) ? RTG.eventMgr.biome.baseBiome : event.biome)) { - - Block originalBlock = event.original; - - if (originalBlock == Blocks.cobblestone || originalBlock == Blocks.planks || originalBlock == Blocks.log - || originalBlock == Blocks.log2 || originalBlock == Blocks.gravel) { - - event.replacement = Blocks.sandstone; - } else if (originalBlock == Blocks.oak_stairs || originalBlock == Blocks.stone_stairs) { - - event.replacement = Blocks.sandstone_stairs; - } - - // The event has to be cancelled in order to override the original block. - if (event.replacement != null) { - - event.setResult(Result.DENY); - } - } - } - - @SubscribeEvent - public void onGetVillageBlockMeta(BiomeEvent.GetVillageBlockMeta event) - { - boolean replaced = false; - - // Use event.biome, if that's null, fall back to our own copy - if (this.isDesertVillageBiome((event.biome == null) ? RTG.eventMgr.biome.baseBiome : event.biome)) { - - Block originalBlock = event.original; - - if (originalBlock == Blocks.log || originalBlock == Blocks.log2 || originalBlock == Blocks.cobblestone) { - - event.replacement = 0; - replaced = true; - } - - if (originalBlock == Blocks.planks) { - - event.replacement = 2; - replaced = true; - } - } - - // The event has to be cancelled in order to override the original block. - if (replaced) { - - event.setResult(Result.DENY); - } - } - - private boolean isDesertVillageBiome(BiomeGenBase biome) - { - if(biome == null) return false; - if ( - BiomeDictionary.isBiomeOfType(biome, Type.HOT) - && - BiomeDictionary.isBiomeOfType(biome, Type.DRY) - && - BiomeDictionary.isBiomeOfType(biome, Type.SANDY) - ) { - return true; - } - - return false; - } -} \ No newline at end of file diff --git a/src/main/java/rtg/event/bus/terraingen/decoratebiomeevent/PreDecorateBiomeRTG.java b/src/main/java/rtg/event/bus/terraingen/decoratebiomeevent/PreDecorateBiomeRTG.java deleted file mode 100644 index d39da652d..000000000 --- a/src/main/java/rtg/event/bus/terraingen/decoratebiomeevent/PreDecorateBiomeRTG.java +++ /dev/null @@ -1,28 +0,0 @@ -package rtg.event.bus.terraingen.decoratebiomeevent; - -import net.minecraftforge.event.terraingen.DecorateBiomeEvent; -import rtg.RTG; -import rtg.world.WorldTypeRTG; -import rtg.world.biome.WorldChunkManagerRTG; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; - -public class PreDecorateBiomeRTG -{ - - public PreDecorateBiomeRTG() - { - - } - - @SubscribeEvent - public void preBiomeDecorate(DecorateBiomeEvent.Pre event) - { - - //Are we in an RTG world? Do we have RTG's chunk manager? - if (event.world.getWorldInfo().getTerrainType() instanceof WorldTypeRTG && event.world.getWorldChunkManager() instanceof WorldChunkManagerRTG) { - - WorldChunkManagerRTG cmr = (WorldChunkManagerRTG) event.world.getWorldChunkManager(); - RTG.eventMgr.biome = cmr.getBiomeDataAt(event.chunkX, event.chunkZ); - } - } -} \ No newline at end of file diff --git a/src/main/java/rtg/event/bus/terraingen/initmapgenevent/InitMapGenRTG.java b/src/main/java/rtg/event/bus/terraingen/initmapgenevent/InitMapGenRTG.java deleted file mode 100644 index 7bb2f4061..000000000 --- a/src/main/java/rtg/event/bus/terraingen/initmapgenevent/InitMapGenRTG.java +++ /dev/null @@ -1,53 +0,0 @@ -package rtg.event.bus.terraingen.initmapgenevent; - -import net.minecraftforge.event.terraingen.InitMapGenEvent; -import rtg.config.rtg.ConfigRTG; -import rtg.util.Logger; -import rtg.world.gen.MapGenCavesRTG; -import rtg.world.gen.MapGenRavineRTG; -import rtg.world.gen.structure.MapGenScatteredFeatureRTG; -import rtg.world.gen.structure.MapGenVillageRTG; -import cpw.mods.fml.common.eventhandler.EventPriority; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; - -public class InitMapGenRTG -{ - - public InitMapGenRTG() - { - - } - - @SubscribeEvent(priority = EventPriority.LOW) - public void onInitMapGen(InitMapGenEvent event) { - - Logger.debug("event type = %s", event.type.toString()); - Logger.debug("event originalGen = %s", event.originalGen.toString()); - - if (event.type == InitMapGenEvent.EventType.SCATTERED_FEATURE) { - event.newGen = new MapGenScatteredFeatureRTG(); - } - else if (event.type == InitMapGenEvent.EventType.VILLAGE) { - - if (ConfigRTG.enableVillageModifications) { - event.newGen = new MapGenVillageRTG(); - } - } - else if (event.type == InitMapGenEvent.EventType.CAVE) { - - if (ConfigRTG.enableCaveModifications) { - - event.newGen = new MapGenCavesRTG(); - } - } - else if (event.type == InitMapGenEvent.EventType.RAVINE) { - - if (ConfigRTG.enableRavineModifications) { - - event.newGen = new MapGenRavineRTG(); - } - } - - Logger.debug("event newGen = %s", event.newGen.toString()); - } -} \ No newline at end of file diff --git a/src/main/java/rtg/event/bus/terraingen/saplinggrowtreeevent/SaplingGrowTreeRTG.java b/src/main/java/rtg/event/bus/terraingen/saplinggrowtreeevent/SaplingGrowTreeRTG.java deleted file mode 100644 index 13137f3ea..000000000 --- a/src/main/java/rtg/event/bus/terraingen/saplinggrowtreeevent/SaplingGrowTreeRTG.java +++ /dev/null @@ -1,132 +0,0 @@ -package rtg.event.bus.terraingen.saplinggrowtreeevent; - -import java.util.ArrayList; -import java.util.Random; - -import net.minecraft.block.Block; -import net.minecraft.init.Blocks; -import net.minecraft.world.World; -import net.minecraft.world.biome.BiomeGenBase; -import net.minecraftforge.event.terraingen.SaplingGrowTreeEvent; -import rtg.config.rtg.ConfigRTG; -import rtg.util.Logger; -import rtg.util.RandomUtil; -import rtg.world.WorldTypeRTG; -import rtg.world.biome.WorldChunkManagerRTG; -import rtg.world.biome.realistic.RealisticBiomeBase; -import rtg.world.gen.feature.tree.rtg.TreeRTG; -import cpw.mods.fml.common.eventhandler.Event.Result; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; - -public class SaplingGrowTreeRTG -{ - - public SaplingGrowTreeRTG() - { - - } - - @SubscribeEvent - public void onSaplingGrowTree(SaplingGrowTreeEvent event) - { - - // Are RTG saplings enabled? - if (!ConfigRTG.enableRTGSaplings) { - return; - } - - // Are we in an RTG world? Do we have RTG's chunk manager? - if (!(event.world.getWorldInfo().getTerrainType() instanceof WorldTypeRTG) || !(event.world.getWorldChunkManager() instanceof WorldChunkManagerRTG)) { - return; - } - - Random rand = event.rand; - - // Should we generate a vanilla tree instead? - if (rand.nextInt(ConfigRTG.rtgTreeChance) != 0) { - Logger.debug("Skipping RTG tree generation."); - return; - } - - World world = event.world; - int x = event.x; - int y = event.y; - int z = event.z; - - Block saplingBlock = world.getBlock(x, y, z); - byte saplingMeta = (byte) saplingBlock.getDamageValue(world, x, y, z); - - WorldChunkManagerRTG cmr = (WorldChunkManagerRTG) world.getWorldChunkManager(); - //BiomeGenBase bgg = cmr.getBiomeGenAt(x, z); - BiomeGenBase bgg = world.getBiomeGenForCoords(x, z); - RealisticBiomeBase rb = RealisticBiomeBase.getBiome(bgg.biomeID); - ArrayList biomeTrees = rb.rtgTrees; - - Logger.debug("Biome = %s", rb.baseBiome.biomeName); - Logger.debug("Ground Sapling Block = %s", saplingBlock.getLocalizedName()); - Logger.debug("Ground Sapling Meta = %d", saplingMeta); - - if (biomeTrees.size() > 0) { - - // First, let's get all of the trees in this biome that match the sapling on the ground. - ArrayList validTrees = new ArrayList(); - - for (int i = 0; i < biomeTrees.size(); i++) { - - Logger.debug("Biome Tree #%d = %s", i, biomeTrees.get(i).getClass().getName()); - Logger.debug("Biome Tree #%d Sapling Block = %s", i, biomeTrees.get(i).saplingBlock.getClass().getName()); - Logger.debug("Biome Tree #%d Sapling Meta = %d", i, biomeTrees.get(i).saplingMeta); - - if (saplingBlock == biomeTrees.get(i).saplingBlock && saplingMeta == biomeTrees.get(i).saplingMeta) { - validTrees.add(biomeTrees.get(i)); - Logger.debug("Valid tree found!"); - } - } - - // If there are valid trees, then proceed; otherwise, let's get out here. - if (validTrees.size() > 0) { - - // Get a random tree from the list of valid trees. - TreeRTG tree = validTrees.get(rand.nextInt(validTrees.size())); - - Logger.debug("Tree = %s", tree.getClass().getName()); - - // Set the trunk size if min/max values have been set. - if (tree.minTrunkSize > 0 && tree.maxTrunkSize > tree.minTrunkSize) { - tree.trunkSize = RandomUtil.getRandomInt(rand, tree.minTrunkSize, tree.maxTrunkSize); - } - - // Set the crown size if min/max values have been set. - if (tree.minCrownSize > 0 && tree.maxCrownSize > tree.minCrownSize) { - tree.crownSize = RandomUtil.getRandomInt(rand, tree.minCrownSize, tree.maxCrownSize); - } - - /** - * Set the generateFlag to what it needs to be for growing trees from saplings, - * generate the tree, and then set it back to what it was before. - * - * TODO: Does this affect the generation of normal RTG trees? - */ - int oldFlag = tree.generateFlag; - tree.generateFlag = 3; - boolean generated = tree.generate(world, rand, x, y, z); - tree.generateFlag = oldFlag; - - if (generated) { - - // Prevent the original tree from generating. - event.setResult(Result.DENY); - - // Sometimes we have to remove the sapling manually because some trees grow around it, leaving the original sapling. - if (world.getBlock(x, y, z) == saplingBlock) { - world.setBlock(x, y, z, Blocks.air, (byte)0, 2); - } - } - } - else { - - Logger.debug("There are no RTG trees associated with the sapling on the ground. Generating a vanilla tree instead."); - } - } - } -} \ No newline at end of file diff --git a/src/main/java/rtg/event/bus/terraingen/worldtypeevent/InitBiomeGensRTG.java b/src/main/java/rtg/event/bus/terraingen/worldtypeevent/InitBiomeGensRTG.java deleted file mode 100644 index 932491580..000000000 --- a/src/main/java/rtg/event/bus/terraingen/worldtypeevent/InitBiomeGensRTG.java +++ /dev/null @@ -1,33 +0,0 @@ -package rtg.event.bus.terraingen.worldtypeevent; - -import net.minecraftforge.event.terraingen.WorldTypeEvent; -import rtg.world.gen.genlayer.RiverRemover; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; - -public class InitBiomeGensRTG -{ - - public InitBiomeGensRTG() - { - - } - - @SubscribeEvent - public void onBiomeGenInit(WorldTypeEvent.InitBiomeGens event) { - - // only handle RTG world type - if (!event.worldType.getWorldTypeName().equalsIgnoreCase("RTG")) return; - - if (event.newBiomeGens[0].getClass().getName().contains("GenLayerEB")) return; - boolean stripRivers = true; // This used to be a config option. Hardcoding until we have a need for the option. - - if (stripRivers) { - try { - event.newBiomeGens = new RiverRemover().riverLess(event.originalBiomeGens); - } catch (ClassCastException ex) { - //throw ex; - // failed attempt because the GenLayers don't end with GenLayerRiverMix - } - } - } -} \ No newline at end of file From bbab809167210b4611cd9b6097a16784c63f6841 Mon Sep 17 00:00:00 2001 From: srs-bsns Date: Sat, 9 Jul 2016 18:57:03 -0400 Subject: [PATCH 04/22] Backported @topisani's Accessor changes in 1.9.4 --- src/main/java/rtg/util/Accessor.java | 95 ++++++++++--------- .../rtg/world/gen/genlayer/RiverRemover.java | 5 +- 2 files changed, 52 insertions(+), 48 deletions(-) diff --git a/src/main/java/rtg/util/Accessor.java b/src/main/java/rtg/util/Accessor.java index c5dc7aa51..e3724fcdc 100755 --- a/src/main/java/rtg/util/Accessor.java +++ b/src/main/java/rtg/util/Accessor.java @@ -2,63 +2,68 @@ import java.lang.reflect.Field; +import java.util.Arrays; + /** - * * @author Zeno410 + * Modified by topisani to allow for multiple possible field names. + * This is useful for catching both the obfuscated and the deobfuscated field. + * Updated and ported to 1.7.10 by srs_bsns */ -public class Accessor{ - private Field field; - private final String fieldName; - public Accessor(String _fieldName) { - fieldName = _fieldName; +public class Accessor { + private final String[] fieldNames; + private Field field; + + public Accessor(String... _fieldName) { + fieldNames = _fieldName; + } + + @SuppressWarnings("unchecked") + public FieldType get(ObjectType object) { + try { + return (FieldType) (field(object).get(object)); + } catch (IllegalArgumentException | IllegalAccessException ex) { + throw new RuntimeException(ex); } + } - private Field field(ObjectType example) { - Class classObject = example.getClass(); - if (field == null) { - try {setField(classObject);} - catch(IllegalAccessException e) { - throw new RuntimeException(e); - } + private Field field(ObjectType example) { + Class classObject = example.getClass(); + if (field == null) { + try { + setField(classObject); + } catch (IllegalAccessException e) { + throw new RuntimeException(e); } - return field; } + return field; + } - private void setField(Class classObject) throws IllegalAccessException{ - // hunts through the class object and all superclasses looking for the field name - Field [] fields; - do { - fields = classObject.getDeclaredFields(); - for (int i = 0; i < fields.length;i ++) { - if (fields[i].getName().contains(fieldName)) { - field = fields[i]; + private void setField(Class classObject) throws IllegalAccessException { + // hunts through the class object and all superclasses looking for the field name + Field[] fields; + do { + fields = classObject.getDeclaredFields(); + for (Field field1 : fields) { + for (String fieldName : fieldNames) { + if (field1.getName().contains(fieldName)) { + field = field1; field.setAccessible(true); return; } } - classObject = classObject.getSuperclass(); - } while (classObject != Object.class); - throw new RuntimeException(fieldName +" not found in class "+classObject.getName()); - } - - public FieldType get(ObjectType object) { - try { - return (FieldType)(field(object).get(object)); - } catch (IllegalArgumentException ex) { - throw new RuntimeException(ex); - } catch (IllegalAccessException ex) { - throw new RuntimeException(ex); } - } + classObject = classObject.getSuperclass(); + } while (classObject != Object.class); + throw new RuntimeException("None of " + Arrays.toString(fieldNames) + " found in class " + classObject.getName()); + } - public void setField(ObjectType object,FieldType fieldValue) { - try { - field(object).set(object, fieldValue); - } catch (IllegalArgumentException ex) { - throw new RuntimeException(ex); - } catch (IllegalAccessException ex) { - throw new RuntimeException(ex); - } + @SuppressWarnings("unused") + public void setField(ObjectType object, FieldType fieldValue) { + try { + field(object).set(object, fieldValue); + } catch (IllegalArgumentException | IllegalAccessException ex) { + throw new RuntimeException(ex); } - - } \ No newline at end of file + } +} \ No newline at end of file diff --git a/src/main/java/rtg/world/gen/genlayer/RiverRemover.java b/src/main/java/rtg/world/gen/genlayer/RiverRemover.java index 5e9c44276..bba2e9730 100755 --- a/src/main/java/rtg/world/gen/genlayer/RiverRemover.java +++ b/src/main/java/rtg/world/gen/genlayer/RiverRemover.java @@ -1,4 +1,3 @@ - package rtg.world.gen.genlayer; import net.minecraft.world.gen.layer.GenLayer; @@ -11,8 +10,8 @@ * @author Zeno410 */ public class RiverRemover { - private Accessor riverMixBiome = - new Accessor("field_75910_b"); + private Accessor riverMixBiome = + new Accessor<>("field_75910_b", "biomePatternGeneratorChain"); public GenLayer [] riverLess(GenLayer [] vanilla) {try { GenLayer riverMixParent = this.riverMixBiome.get((GenLayerRiverMix) vanilla[0]); From 452c1ed46956823eff70ce9c32b95929f61f70fa Mon Sep 17 00:00:00 2001 From: srs-bsns Date: Sat, 9 Jul 2016 18:59:26 -0400 Subject: [PATCH 05/22] Updated build.gradle with dubugger settings --- build.gradle | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/build.gradle b/build.gradle index 4d1165c3a..1e5debc66 100644 --- a/build.gradle +++ b/build.gradle @@ -56,3 +56,13 @@ def parseprops(File cfg) { return (new ConfigSlurper().parse(prop)) } } + +// run 'gradle -DEBUG [runClient|runServer]' for a debug session +allprojects { + tasks.withType(JavaExec) { + jvmArgs "-Xms2G", "-Xmx4G" + if (System.getProperty('EBUG', 'false') == 'true') { + jvmArgs '-agentlib:jdwp=transport=dt_socket,address=localhost:5005,server=y,suspend=y' + } + } +} From 3ee25d65d007d2713a43eb7f972ab2aeb050670f Mon Sep 17 00:00:00 2001 From: srs-bsns Date: Mon, 11 Jul 2016 16:17:04 -0400 Subject: [PATCH 06/22] More Event Manager refinement --- src/main/java/rtg/RTG.java | 45 +- src/main/java/rtg/event/EventManagerRTG.java | 584 ++++++++----------- 2 files changed, 269 insertions(+), 360 deletions(-) diff --git a/src/main/java/rtg/RTG.java b/src/main/java/rtg/RTG.java index ede800486..6db8cd6a5 100755 --- a/src/main/java/rtg/RTG.java +++ b/src/main/java/rtg/RTG.java @@ -2,6 +2,12 @@ import java.util.ArrayList; +import cpw.mods.fml.common.Mod; +import cpw.mods.fml.common.Mod.EventHandler; +import cpw.mods.fml.common.Mod.Instance; +import cpw.mods.fml.common.event.FMLPostInitializationEvent; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import cpw.mods.fml.common.event.FMLServerStoppedEvent; import net.minecraft.world.gen.structure.MapGenStructureIO; import net.minecraftforge.common.MinecraftForge; import rtg.api.event.BiomeConfigEvent; @@ -33,14 +39,9 @@ import rtg.world.biome.realistic.vanilla.RealisticBiomeVanillaBase; import rtg.world.gen.structure.MapGenScatteredFeatureRTG; import rtg.world.gen.structure.MapGenVillageRTG; -import cpw.mods.fml.common.Mod; -import cpw.mods.fml.common.Mod.EventHandler; -import cpw.mods.fml.common.Mod.Instance; -import cpw.mods.fml.common.event.FMLInitializationEvent; -import cpw.mods.fml.common.event.FMLPostInitializationEvent; -import cpw.mods.fml.common.event.FMLPreInitializationEvent; -import cpw.mods.fml.common.event.FMLServerStoppedEvent; + +@SuppressWarnings({"WeakerAccess", "unused"}) //@Mod(modid = "RTG", name = "Realistic Terrain Generaton", version = "0.8.0d", dependencies = "required-after:Forge@[10.13.4.1448,)", acceptableRemoteVersions = "*") @Mod(modid = ModInfo.MOD_ID, name = ModInfo.MOD_NAME, version = ModInfo.MOD_VERSION, dependencies = "required-after:Forge@[" + ModInfo.FORGE_DEP + ",)" + ModInfo.MOD_DEPS, acceptableRemoteVersions = "*") public class RTG { @@ -58,17 +59,15 @@ public ConfigManager configManager(int dimension) { } @EventHandler - public void fmlLifeCycleEvent(FMLPreInitializationEvent event) + public void preInit(FMLPreInitializationEvent event) { instance = this; MapGenStructureIO.registerStructure(MapGenScatteredFeatureRTG.Start.class, "rtg_MapGenScatteredFeatureRTG"); MapGenStructureIO.registerStructure(MapGenVillageRTG.Start.class, "rtg_MapGenVillageRTG"); - + + Logger.info("[FMLPreInitializationEvent] Creating RTG's EventManager"); eventMgr = new EventManagerRTG(); - Logger.info("[FMLPreInitializationEvent] Registering RTG's event handlers..."); - eventMgr.registerEventHandlers(); - Logger.info("[FMLPreInitializationEvent] RTG's event handlers have been registered successfully."); MinecraftForge.EVENT_BUS.post(new BiomeConfigEvent.Pre()); @@ -83,14 +82,10 @@ public void fmlLifeCycleEvent(FMLPreInitializationEvent event) worldtype = new WorldTypeRTG("RTG"); } - @EventHandler - public void fmlLifeCycleEvent(FMLInitializationEvent event) - { +// @EventHandler public void init(FMLInitializationEvent event) {} - } - @EventHandler - public void fmlLifeCycle(FMLPostInitializationEvent event) + public void postInit(FMLPostInitializationEvent event) { RealisticBiomeVanillaBase.addBiomes(); @@ -119,16 +114,16 @@ public void fmlLifeCycle(FMLPostInitializationEvent event) /* @EventHandler - public void fmlLifeCycle(FMLServerAboutToStartEvent event) {} + public void serverAboutToStart(FMLServerAboutToStartEvent event) {} @EventHandler - public void fmlLifeCycle(FMLServerStartingEvent event) {} + public void serverStarting(FMLServerStartingEvent event) {} @EventHandler - public void fmlLifeCycle(FMLServerStartedEvent event) {} + public void serverStarted(FMLServerStartedEvent event) {} @EventHandler - public void fmlLifeCycle(FMLServerStoppingEvent event) {} + public void serverStopping(FMLServerStoppingEvent event) {} */ @@ -140,10 +135,10 @@ public void runOnNextServerCloseOnly(Runnable action) { serverCloseActions.add(action); } - private ArrayList oneShotServerCloseActions = new ArrayList(); - private ArrayList serverCloseActions = new ArrayList(); + private ArrayList oneShotServerCloseActions = new ArrayList<>(); + private ArrayList serverCloseActions = new ArrayList<>(); @EventHandler - public void fmlLifeCycle(FMLServerStoppedEvent event) + public void serverStopped(FMLServerStoppedEvent event) { for (Runnable action: serverCloseActions) { action.run(); diff --git a/src/main/java/rtg/event/EventManagerRTG.java b/src/main/java/rtg/event/EventManagerRTG.java index 130457b9c..a5d26588b 100755 --- a/src/main/java/rtg/event/EventManagerRTG.java +++ b/src/main/java/rtg/event/EventManagerRTG.java @@ -4,15 +4,14 @@ import java.util.Random; import java.util.WeakHashMap; +import cpw.mods.fml.common.eventhandler.Event.Result; +import cpw.mods.fml.common.eventhandler.EventPriority; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; -import net.minecraftforge.common.BiomeDictionary; -import net.minecraftforge.common.BiomeDictionary.Type; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.terraingen.BiomeEvent; -import net.minecraftforge.event.terraingen.DecorateBiomeEvent; import net.minecraftforge.event.terraingen.InitMapGenEvent; import net.minecraftforge.event.terraingen.OreGenEvent; import net.minecraftforge.event.terraingen.SaplingGrowTreeEvent; @@ -33,80 +32,63 @@ import rtg.world.gen.genlayer.RiverRemover; import rtg.world.gen.structure.MapGenScatteredFeatureRTG; import rtg.world.gen.structure.MapGenVillageRTG; -import cpw.mods.fml.common.eventhandler.Event.Result; -import cpw.mods.fml.common.eventhandler.EventPriority; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; +@SuppressWarnings({"WeakerAccess","unused"}) public class EventManagerRTG { - - public EventManagerRTG.LoadChunkRTG loadChunkRTG = new EventManagerRTG.LoadChunkRTG(); - public EventManagerRTG.WorldLoadRTG worldLoadRTG = new EventManagerRTG.WorldLoadRTG(); - public EventManagerRTG.WorldUnloadRTG worldUnloadRTG = new EventManagerRTG.WorldUnloadRTG(); - public EventManagerRTG.GenerateMinableRTG generateMinableRTG = new EventManagerRTG.GenerateMinableRTG(); - public EventManagerRTG.GetVillageBlockRTG getVillageBlockRTG = new EventManagerRTG.GetVillageBlockRTG(); - public EventManagerRTG.PreDecorateBiomeRTG preDecorateBiomeRTG = new EventManagerRTG.PreDecorateBiomeRTG(); - public EventManagerRTG.InitMapGenRTG initMapGenRTG = new EventManagerRTG.InitMapGenRTG(); - public EventManagerRTG.SaplingGrowTreeRTG saplingGrowTreeRTG = new EventManagerRTG.SaplingGrowTreeRTG(); - public EventManagerRTG.InitBiomeGensRTG initBiomeGensRTG = new EventManagerRTG.InitBiomeGensRTG(); - - private RealisticBiomeBase biome = null; - - private WeakHashMap> chunkLoadEvents = - new WeakHashMap> (); - - public EventManagerRTG() - { - - } - - public void registerEventHandlers() - { - MinecraftForge.EVENT_BUS.register(loadChunkRTG); - MinecraftForge.EVENT_BUS.register(worldLoadRTG); - MinecraftForge.EVENT_BUS.register(worldUnloadRTG); - MinecraftForge.ORE_GEN_BUS.register(generateMinableRTG); - MinecraftForge.TERRAIN_GEN_BUS.register(getVillageBlockRTG); - MinecraftForge.TERRAIN_GEN_BUS.register(preDecorateBiomeRTG); - MinecraftForge.TERRAIN_GEN_BUS.register(initMapGenRTG); - MinecraftForge.TERRAIN_GEN_BUS.register(saplingGrowTreeRTG); - MinecraftForge.TERRAIN_GEN_BUS.register(initBiomeGensRTG); + private final LoadChunkRTG LOAD_CHUNK_RTG = new LoadChunkRTG(); + private final GenerateOreRTG GENERATE_ORE_RTG = new GenerateOreRTG(); + private final InitBiomeGensRTG INIT_BIOME_GENS_RTG = new InitBiomeGensRTG(); + private final BiomeFeaturesRTG BIOME_FEATURES_RTG = new BiomeFeaturesRTG(); + private final CustomTreesRTG CUSTOM_TREES_RTG = new CustomTreesRTG(); + + public final WorldEventsRTG DISPLAY_SEED_RTG = new WorldEventsRTG(); + public final RTGEventRegister RTG_EVENTS_ENABLER = new RTGEventRegister(); + public final RTGEventUnregister RTG_EVENTS_DISABLER = new RTGEventUnregister(); + + private WeakHashMap> chunkLoadEvents = new WeakHashMap<>(); + private RealisticBiomeBase biome = null; + private boolean REGISTERED = false; + private long WORLD_SEED; + + public EventManagerRTG() { + // These should be registered once, and stay registered -srs + MinecraftForge.TERRAIN_GEN_BUS.register(RTG_EVENTS_ENABLER); + MinecraftForge.EVENT_BUS.register(RTG_EVENTS_DISABLER); + MinecraftForge.EVENT_BUS.register(DISPLAY_SEED_RTG); + Logger.info("RTG EventManager Initialised"); } - - public void unRegisterEventHandlers() + + public class LoadChunkRTG { + LoadChunkRTG() { + Logger.debug("RTG Event System: Initialising LoadChunkRTG"); + } - /** - * The onWorldLoad and onWorldUnload handlers must always be registered. - * - * MinecraftForge.EVENT_BUS.unregister(worldLoadRTG); - * MinecraftForge.EVENT_BUS.unregister(worldUnloadRTG); - */ - - MinecraftForge.EVENT_BUS.unregister(loadChunkRTG); - MinecraftForge.ORE_GEN_BUS.unregister(generateMinableRTG); - MinecraftForge.TERRAIN_GEN_BUS.unregister(getVillageBlockRTG); - MinecraftForge.TERRAIN_GEN_BUS.unregister(preDecorateBiomeRTG); - MinecraftForge.TERRAIN_GEN_BUS.unregister(initMapGenRTG); - MinecraftForge.TERRAIN_GEN_BUS.unregister(saplingGrowTreeRTG); - MinecraftForge.TERRAIN_GEN_BUS.unregister(initBiomeGensRTG); + @SubscribeEvent + public void loadChunkRTG(ChunkEvent.Load event) { + Acceptor acceptor = chunkLoadEvents.get(event.world.provider.dimensionId); + if (acceptor != null) { + acceptor.accept(event); + } + } } - public void setDimensionChunkLoadEvent(int dimension, Acceptor action) { - chunkLoadEvents.put(dimension, action); - } - - public class GenerateMinableRTG + public class GenerateOreRTG { + GenerateOreRTG() { + Logger.debug("RTG Event System: Initialising GenerateOresRTG"); + } + @SubscribeEvent public void onGenerateMinable(OreGenEvent.GenerateMinable event) { switch (event.type) { - + case COAL: if (!ConfigRTG.generateOreCoal) { event.setResult(Result.DENY); } return; - + case IRON: if (!ConfigRTG.generateOreIron) { event.setResult(Result.DENY); } return; @@ -114,334 +96,266 @@ public void onGenerateMinable(OreGenEvent.GenerateMinable event) { case REDSTONE: if (!ConfigRTG.generateOreRedstone) { event.setResult(Result.DENY); } return; - + case GOLD: if (!ConfigRTG.generateOreGold) { event.setResult(Result.DENY); } return; - + case LAPIS: if (!ConfigRTG.generateOreLapis) { event.setResult(Result.DENY); } return; - + case DIAMOND: if (!ConfigRTG.generateOreDiamond) { event.setResult(Result.DENY); } return; - + default: - return; } } } - - public class GetVillageBlockRTG + + public class InitBiomeGensRTG { - @SubscribeEvent - public void onGetVillageBlockID(BiomeEvent.GetVillageBlockID event) + InitBiomeGensRTG() { + Logger.debug("RTG Event System: Initialising InitBiomeGensRTG"); + } - // Use event.biome, if that's null, fall back to our own copy - if (this.isDesertVillageBiome((event.biome == null) ? RTG.eventMgr.biome.baseBiome : event.biome)) { + @SubscribeEvent + public void initBiomeGensRTG(WorldTypeEvent.InitBiomeGens event) { - Block originalBlock = event.original; + if (event.newBiomeGens[0].getClass().getName().contains("GenLayerEB")) return; - if (originalBlock == Blocks.cobblestone || originalBlock == Blocks.planks || originalBlock == Blocks.log - || originalBlock == Blocks.log2 || originalBlock == Blocks.gravel) { + try { + event.newBiomeGens = new RiverRemover().riverLess(event.originalBiomeGens); + } catch (ClassCastException ex) { + //throw ex; + // failed attempt because the GenLayers don't end with GenLayerRiverMix + } + } + } - event.replacement = Blocks.sandstone; - } else if (originalBlock == Blocks.oak_stairs || originalBlock == Blocks.stone_stairs) { + public class BiomeFeaturesRTG + { + BiomeFeaturesRTG() { + Logger.debug("RTG Event System: Initialising BiomeFeaturesRTG"); + } - event.replacement = Blocks.sandstone_stairs; - } + @SubscribeEvent(priority = EventPriority.LOW) + public void doBiomeFeatures(InitMapGenEvent event) { - // The event has to be cancelled in order to override the original block. - if (event.replacement != null) { + Logger.debug("event type = %s", event.type.toString()); + Logger.debug("event originalGen = %s", event.originalGen.toString()); - event.setResult(Result.DENY); - } + switch (event.type) { + case SCATTERED_FEATURE: + event.newGen = new MapGenScatteredFeatureRTG(); + break; + + case VILLAGE: + if (ConfigRTG.enableVillageModifications) { + event.newGen = new MapGenVillageRTG(); + } + break; + + case CAVE: + if (ConfigRTG.enableCaveModifications) { + event.newGen = new MapGenCavesRTG(); + } + break; + + case RAVINE: + if (ConfigRTG.enableRavineModifications) { + event.newGen = new MapGenRavineRTG(); + } + break; + + default: } + Logger.debug("event newGen = %s", event.newGen.toString()); + } + } + + public class CustomTreesRTG + { + CustomTreesRTG() { + Logger.debug("RTG Event System: Initialising CustomTreesRTG"); } - + @SubscribeEvent - public void onGetVillageBlockMeta(BiomeEvent.GetVillageBlockMeta event) - { - boolean replaced = false; + public void onSaplingGrowTree(SaplingGrowTreeEvent event) { + // Are RTG saplings enabled? + if (!ConfigRTG.enableRTGSaplings) { return; } - // Use event.biome, if that's null, fall back to our own copy - if (this.isDesertVillageBiome((event.biome == null) ? RTG.eventMgr.biome.baseBiome : event.biome)) { + Random rand = event.rand; + // Should we generate a vanilla tree instead? + if (rand.nextInt(ConfigRTG.rtgTreeChance) != 0) { - Block originalBlock = event.original; + Logger.debug("Skipping RTG tree generation."); + return; + } - if (originalBlock == Blocks.log || originalBlock == Blocks.log2 || originalBlock == Blocks.cobblestone) { + World world = event.world; + int x = event.x; + int y = event.y; + int z = event.z; - event.replacement = 0; - replaced = true; - } + Block saplingBlock = world.getBlock(x, y, z); + byte saplingMeta = (byte) saplingBlock.getDamageValue(world, x, y, z); - if (originalBlock == Blocks.planks) { + WorldChunkManagerRTG cmr = (WorldChunkManagerRTG) world.getWorldChunkManager(); + //BiomeGenBase bgg = cmr.getBiomeGenAt(x, z); + BiomeGenBase bgg = world.getBiomeGenForCoords(x, z); + RealisticBiomeBase rb = RealisticBiomeBase.getBiome(bgg.biomeID); + ArrayList biomeTrees = rb.rtgTrees; - event.replacement = 2; - replaced = true; - } - } + Logger.debug("Biome = %s", rb.baseBiome.biomeName); + Logger.debug("Ground Sapling Block = %s", saplingBlock.getLocalizedName()); + Logger.debug("Ground Sapling Meta = %d", saplingMeta); - // The event has to be cancelled in order to override the original block. - if (replaced) { + if (biomeTrees.size() > 0) { + // First, let's get all of the trees in this biome that match the sapling on the ground. + ArrayList validTrees = new ArrayList<>(); - event.setResult(Result.DENY); - } - } - - private boolean isDesertVillageBiome(BiomeGenBase biome) - { - if(biome == null) return false; - if ( - BiomeDictionary.isBiomeOfType(biome, Type.HOT) - && - BiomeDictionary.isBiomeOfType(biome, Type.DRY) - && - BiomeDictionary.isBiomeOfType(biome, Type.SANDY) - ) { - return true; - } + for (int i = 0; i < biomeTrees.size(); i++) { - return false; - } - } - - public class InitBiomeGensRTG - { - @SubscribeEvent - public void onBiomeGenInit(WorldTypeEvent.InitBiomeGens event) { - - // only handle RTG world type - if (!event.worldType.getWorldTypeName().equalsIgnoreCase("RTG")) return; + Logger.debug("Biome Tree #%d = %s", i, biomeTrees.get(i).getClass().getName()); + Logger.debug("Biome Tree #%d Sapling Block = %s", i, biomeTrees.get(i).saplingBlock.getClass().getName()); + Logger.debug("Biome Tree #%d Sapling Meta = %d", i, biomeTrees.get(i).saplingMeta); - if (event.newBiomeGens[0].getClass().getName().contains("GenLayerEB")) return; - boolean stripRivers = true; // This used to be a config option. Hardcoding until we have a need for the option. - - if (stripRivers) { - try { - event.newBiomeGens = new RiverRemover().riverLess(event.originalBiomeGens); - } catch (ClassCastException ex) { - //throw ex; - // failed attempt because the GenLayers don't end with GenLayerRiverMix - } - } - } - } - - public class InitMapGenRTG - { - @SubscribeEvent(priority = EventPriority.LOW) - public void onInitMapGen(InitMapGenEvent event) { - - Logger.debug("event type = %s", event.type.toString()); - Logger.debug("event originalGen = %s", event.originalGen.toString()); - - if (event.type == InitMapGenEvent.EventType.SCATTERED_FEATURE) { - event.newGen = new MapGenScatteredFeatureRTG(); - } - else if (event.type == InitMapGenEvent.EventType.VILLAGE) { - - if (ConfigRTG.enableVillageModifications) { - event.newGen = new MapGenVillageRTG(); - } - } - else if (event.type == InitMapGenEvent.EventType.CAVE) { - - if (ConfigRTG.enableCaveModifications) { - - event.newGen = new MapGenCavesRTG(); + if (saplingBlock == biomeTrees.get(i).saplingBlock && saplingMeta == biomeTrees.get(i).saplingMeta) { + + validTrees.add(biomeTrees.get(i)); + Logger.debug("Valid tree found!"); + } } - } - else if (event.type == InitMapGenEvent.EventType.RAVINE) { - - if (ConfigRTG.enableRavineModifications) { - - event.newGen = new MapGenRavineRTG(); + // If there are valid trees, then proceed; otherwise, let's get out here. + if (validTrees.size() > 0) { + // Get a random tree from the list of valid trees. + TreeRTG tree = validTrees.get(rand.nextInt(validTrees.size())); + + Logger.debug("Tree = %s", tree.getClass().getName()); + + // Set the trunk size if min/max values have been set. + if (tree.minTrunkSize > 0 && tree.maxTrunkSize > tree.minTrunkSize) { + + tree.trunkSize = RandomUtil.getRandomInt(rand, tree.minTrunkSize, tree.maxTrunkSize); + } + + // Set the crown size if min/max values have been set. + if (tree.minCrownSize > 0 && tree.maxCrownSize > tree.minCrownSize) { + + tree.crownSize = RandomUtil.getRandomInt(rand, tree.minCrownSize, tree.maxCrownSize); + } + + /** + * Set the generateFlag to what it needs to be for growing trees from saplings, + * generate the tree, and then set it back to what it was before. + * + * TODO: Does this affect the generation of normal RTG trees? + */ + int oldFlag = tree.generateFlag; + tree.generateFlag = 3; + boolean generated = tree.generate(world, rand, x, y, z); + tree.generateFlag = oldFlag; + + if (generated) { + + // Prevent the original tree from generating. + event.setResult(Result.DENY); + + // Sometimes we have to remove the sapling manually because some trees grow around it, leaving the original sapling. + if (world.getBlock(x, y, z) == saplingBlock) { + world.setBlock(x, y, z, Blocks.air, (byte)0, 2); + } + } } - } - - Logger.debug("event newGen = %s", event.newGen.toString()); - } - } - - public class LoadChunkRTG - { - @SubscribeEvent - public void onChunkLoadEvent(ChunkEvent.Load loadEvent) { - Integer dimension = loadEvent.world.provider.dimensionId; - Acceptor acceptor = chunkLoadEvents.get(dimension); - if (acceptor != null) { - acceptor.accept(loadEvent); + else Logger.debug("There are no RTG trees associated with the sapling on the ground." + + " Generating a vanilla tree instead."); } } } - - public class PreDecorateBiomeRTG + + public class WorldEventsRTG { + WorldEventsRTG() { + Logger.debug("RTG Event System: Initialising WorldEventsRTG"); + } + @SubscribeEvent - public void preBiomeDecorate(DecorateBiomeEvent.Pre event) - { + public void logWorldSeed(WorldEvent.Load event) { + // This event fires for each dimension loaded (and then one last time in which it returns 0?), + // so initialise a field to 0 and set it to the world seed and only display it in the log once. + if (WORLD_SEED != event.world.getSeed() && event.world.getSeed() != 0) { - //Are we in an RTG world? Do we have RTG's chunk manager? - if (event.world.getWorldInfo().getTerrainType() instanceof WorldTypeRTG && event.world.getWorldChunkManager() instanceof WorldChunkManagerRTG) { - - WorldChunkManagerRTG cmr = (WorldChunkManagerRTG) event.world.getWorldChunkManager(); - RTG.eventMgr.biome = cmr.getBiomeDataAt(event.chunkX, event.chunkZ); + WORLD_SEED = event.world.getSeed(); + Logger.info("World Seed: " + WORLD_SEED); } } + + @SubscribeEvent + public void resetWorldSeed(WorldEvent.Unload event) { + // reset WORLD_SEED so that it logs on the next server start if the seed is the same as the last load. + WORLD_SEED = 0; + } } - - public class SaplingGrowTreeRTG - { - @SubscribeEvent - public void onSaplingGrowTree(SaplingGrowTreeEvent event) - { - - // Are RTG saplings enabled? - if (!ConfigRTG.enableRTGSaplings) { - return; - } - - // Are we in an RTG world? Do we have RTG's chunk manager? - if (!(event.world.getWorldInfo().getTerrainType() instanceof WorldTypeRTG) || !(event.world.getWorldChunkManager() instanceof WorldChunkManagerRTG)) { - return; - } - - Random rand = event.rand; - - // Should we generate a vanilla tree instead? - if (rand.nextInt(ConfigRTG.rtgTreeChance) != 0) { - Logger.debug("Skipping RTG tree generation."); - return; - } - - World world = event.world; - int x = event.x; - int y = event.y; - int z = event.z; - - Block saplingBlock = world.getBlock(x, y, z); - byte saplingMeta = (byte) saplingBlock.getDamageValue(world, x, y, z); - - WorldChunkManagerRTG cmr = (WorldChunkManagerRTG) world.getWorldChunkManager(); - //BiomeGenBase bgg = cmr.getBiomeGenAt(x, z); - BiomeGenBase bgg = world.getBiomeGenForCoords(x, z); - RealisticBiomeBase rb = RealisticBiomeBase.getBiome(bgg.biomeID); - ArrayList biomeTrees = rb.rtgTrees; - - Logger.debug("Biome = %s", rb.baseBiome.biomeName); - Logger.debug("Ground Sapling Block = %s", saplingBlock.getLocalizedName()); - Logger.debug("Ground Sapling Meta = %d", saplingMeta); - - if (biomeTrees.size() > 0) { - - // First, let's get all of the trees in this biome that match the sapling on the ground. - ArrayList validTrees = new ArrayList(); - - for (int i = 0; i < biomeTrees.size(); i++) { - - Logger.debug("Biome Tree #%d = %s", i, biomeTrees.get(i).getClass().getName()); - Logger.debug("Biome Tree #%d Sapling Block = %s", i, biomeTrees.get(i).saplingBlock.getClass().getName()); - Logger.debug("Biome Tree #%d Sapling Meta = %d", i, biomeTrees.get(i).saplingMeta); - - if (saplingBlock == biomeTrees.get(i).saplingBlock && saplingMeta == biomeTrees.get(i).saplingMeta) { - validTrees.add(biomeTrees.get(i)); - Logger.debug("Valid tree found!"); - } - } - - // If there are valid trees, then proceed; otherwise, let's get out here. - if (validTrees.size() > 0) { - - // Get a random tree from the list of valid trees. - TreeRTG tree = validTrees.get(rand.nextInt(validTrees.size())); - - Logger.debug("Tree = %s", tree.getClass().getName()); - - // Set the trunk size if min/max values have been set. - if (tree.minTrunkSize > 0 && tree.maxTrunkSize > tree.minTrunkSize) { - tree.trunkSize = RandomUtil.getRandomInt(rand, tree.minTrunkSize, tree.maxTrunkSize); - } - - // Set the crown size if min/max values have been set. - if (tree.minCrownSize > 0 && tree.maxCrownSize > tree.minCrownSize) { - tree.crownSize = RandomUtil.getRandomInt(rand, tree.minCrownSize, tree.maxCrownSize); - } - - /** - * Set the generateFlag to what it needs to be for growing trees from saplings, - * generate the tree, and then set it back to what it was before. - * - * TODO: Does this affect the generation of normal RTG trees? - */ - int oldFlag = tree.generateFlag; - tree.generateFlag = 3; - boolean generated = tree.generate(world, rand, x, y, z); - tree.generateFlag = oldFlag; - - if (generated) { - - // Prevent the original tree from generating. - event.setResult(Result.DENY); - - // Sometimes we have to remove the sapling manually because some trees grow around it, leaving the original sapling. - if (world.getBlock(x, y, z) == saplingBlock) { - world.setBlock(x, y, z, Blocks.air, (byte)0, 2); - } - } - } - else { - - Logger.debug("There are no RTG trees associated with the sapling on the ground. Generating a vanilla tree instead."); - } - } - } - } - - public class WorldLoadRTG + + public class RTGEventRegister { + RTGEventRegister() { + Logger.debug("RTG Event System: Initialising RTGEventRegister"); + } + @SubscribeEvent - public void onWorldLoad(WorldEvent.Load event) { - - if (!(event.world.getWorldInfo().getTerrainType() instanceof WorldTypeRTG)) { - - Logger.info("[onWorldLoad] Unregistering RTG's event handlers..."); - RTG.eventMgr.unRegisterEventHandlers(); - Logger.info("[onWorldLoad] RTG's event handlers have been unregistered successfully."); - - return; + public void registerRTGEventHandlers(WorldTypeEvent.InitBiomeGens event) { + if (event.worldType instanceof WorldTypeRTG) { + if (!REGISTERED) { + Logger.info("Registering RTG's Terrain Event Handlers..."); + RTG.eventMgr.registerEventHandlers(); + if (REGISTERED) Logger.info("RTG's Terrain Event Handlers have been registered successfully."); + } } - - Logger.info("[onWorldLoad] Re-registering RTG's event handlers..."); - RTG.eventMgr.registerEventHandlers(); - Logger.info("[onWorldLoad] RTG's event handlers have been re-registered successfully."); - - if (event.world.provider.dimensionId == 0) { - - Logger.info("World Seed: %d", event.world.getSeed()); + else { + if (REGISTERED) RTG.eventMgr.unRegisterEventHandlers(); } } } - - public class WorldUnloadRTG + + public class RTGEventUnregister { - @SubscribeEvent - public void onWorldUnload(WorldEvent.Unload event) { + RTGEventUnregister() { + Logger.debug("RTG Event System: Initialising RTGEventUnregister"); + } - if (event.world.getWorldInfo().getTerrainType() instanceof WorldTypeRTG) { - - Logger.info("[onWorldUnload] Unregistering RTG's event handlers..."); - RTG.eventMgr.unRegisterEventHandlers(); - Logger.info("[onWorldUnload] RTG's event handlers have been unregistered successfully."); - } - else { - - Logger.info("[onWorldUnload] Re-registering RTG's event handlers..."); - RTG.eventMgr.registerEventHandlers(); - Logger.info("[onWorldUnload] RTG's event handlers have been re-registered successfully."); + @SubscribeEvent + public void unregisterRTGEventHandlers(WorldEvent.Unload event) { + if (REGISTERED) { + Logger.info("Unregistering RTG's Terrain Event Handlers..."); + RTG.eventMgr.unRegisterEventHandlers(); + if (!REGISTERED) Logger.info("RTG's Terrain Event Handlers have been unregistered successfully."); } } } + + public void registerEventHandlers() { + MinecraftForge.EVENT_BUS .register(LOAD_CHUNK_RTG); + MinecraftForge.ORE_GEN_BUS .register(GENERATE_ORE_RTG); + MinecraftForge.TERRAIN_GEN_BUS .register(INIT_BIOME_GENS_RTG); + MinecraftForge.TERRAIN_GEN_BUS .register(BIOME_FEATURES_RTG); + MinecraftForge.TERRAIN_GEN_BUS .register(CUSTOM_TREES_RTG); + REGISTERED = true; + } + + public void unRegisterEventHandlers() { + MinecraftForge.EVENT_BUS .unregister(LOAD_CHUNK_RTG); + MinecraftForge.ORE_GEN_BUS .unregister(GENERATE_ORE_RTG); + MinecraftForge.TERRAIN_GEN_BUS .unregister(INIT_BIOME_GENS_RTG); + MinecraftForge.TERRAIN_GEN_BUS .unregister(BIOME_FEATURES_RTG); + MinecraftForge.TERRAIN_GEN_BUS .unregister(CUSTOM_TREES_RTG); + REGISTERED = false; + } + + public void setDimensionChunkLoadEvent(int dimension, Acceptor action) { + chunkLoadEvents.put(dimension, action); + } } From 97d6683f7acf7a9248fa8b887fcb01ea83d50c6d Mon Sep 17 00:00:00 2001 From: srs-bsns Date: Mon, 11 Jul 2016 19:58:29 -0400 Subject: [PATCH 07/22] Fix for AdminCommandsToolbox causing event handlers to unregister on running server --- src/main/java/rtg/RTG.java | 6 ++++++ src/main/java/rtg/event/EventManagerRTG.java | 22 ++++---------------- 2 files changed, 10 insertions(+), 18 deletions(-) diff --git a/src/main/java/rtg/RTG.java b/src/main/java/rtg/RTG.java index 6db8cd6a5..53c90edbe 100755 --- a/src/main/java/rtg/RTG.java +++ b/src/main/java/rtg/RTG.java @@ -148,5 +148,11 @@ public void serverStopped(FMLServerStoppedEvent event) } oneShotServerCloseActions.clear(); + if (eventMgr.isRegistered()) { + Logger.info("Unregistering RTG's Terrain Event Handlers..."); + RTG.eventMgr.unRegisterEventHandlers(); + if (!eventMgr.isRegistered()) Logger.info("RTG's Terrain Event Handlers have been unregistered successfully."); + } + } } diff --git a/src/main/java/rtg/event/EventManagerRTG.java b/src/main/java/rtg/event/EventManagerRTG.java index a5d26588b..12a313f41 100755 --- a/src/main/java/rtg/event/EventManagerRTG.java +++ b/src/main/java/rtg/event/EventManagerRTG.java @@ -44,7 +44,6 @@ public class EventManagerRTG public final WorldEventsRTG DISPLAY_SEED_RTG = new WorldEventsRTG(); public final RTGEventRegister RTG_EVENTS_ENABLER = new RTGEventRegister(); - public final RTGEventUnregister RTG_EVENTS_DISABLER = new RTGEventUnregister(); private WeakHashMap> chunkLoadEvents = new WeakHashMap<>(); private RealisticBiomeBase biome = null; @@ -54,7 +53,6 @@ public class EventManagerRTG public EventManagerRTG() { // These should be registered once, and stay registered -srs MinecraftForge.TERRAIN_GEN_BUS.register(RTG_EVENTS_ENABLER); - MinecraftForge.EVENT_BUS.register(RTG_EVENTS_DISABLER); MinecraftForge.EVENT_BUS.register(DISPLAY_SEED_RTG); Logger.info("RTG EventManager Initialised"); } @@ -321,22 +319,6 @@ public void registerRTGEventHandlers(WorldTypeEvent.InitBiomeGens event) { } } - public class RTGEventUnregister - { - RTGEventUnregister() { - Logger.debug("RTG Event System: Initialising RTGEventUnregister"); - } - - @SubscribeEvent - public void unregisterRTGEventHandlers(WorldEvent.Unload event) { - if (REGISTERED) { - Logger.info("Unregistering RTG's Terrain Event Handlers..."); - RTG.eventMgr.unRegisterEventHandlers(); - if (!REGISTERED) Logger.info("RTG's Terrain Event Handlers have been unregistered successfully."); - } - } - } - public void registerEventHandlers() { MinecraftForge.EVENT_BUS .register(LOAD_CHUNK_RTG); MinecraftForge.ORE_GEN_BUS .register(GENERATE_ORE_RTG); @@ -358,4 +340,8 @@ public void unRegisterEventHandlers() { public void setDimensionChunkLoadEvent(int dimension, Acceptor action) { chunkLoadEvents.put(dimension, action); } + + public boolean isRegistered() { + return REGISTERED; + } } From 2bc25d0ce61b97b738140e680717a87d9dc19479 Mon Sep 17 00:00:00 2001 From: WhichOnesPink Date: Tue, 12 Jul 2016 14:08:47 +0100 Subject: [PATCH 08/22] Removed @SuppressWarnings --- src/main/java/rtg/RTG.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/rtg/RTG.java b/src/main/java/rtg/RTG.java index 6db8cd6a5..0718e61ab 100755 --- a/src/main/java/rtg/RTG.java +++ b/src/main/java/rtg/RTG.java @@ -41,7 +41,6 @@ import rtg.world.gen.structure.MapGenVillageRTG; -@SuppressWarnings({"WeakerAccess", "unused"}) //@Mod(modid = "RTG", name = "Realistic Terrain Generaton", version = "0.8.0d", dependencies = "required-after:Forge@[10.13.4.1448,)", acceptableRemoteVersions = "*") @Mod(modid = ModInfo.MOD_ID, name = ModInfo.MOD_NAME, version = ModInfo.MOD_VERSION, dependencies = "required-after:Forge@[" + ModInfo.FORGE_DEP + ",)" + ModInfo.MOD_DEPS, acceptableRemoteVersions = "*") public class RTG { From 0364f82f43fc316fe80957779243ce5c5d5a51e5 Mon Sep 17 00:00:00 2001 From: WhichOnesPink Date: Tue, 12 Jul 2016 14:09:46 +0100 Subject: [PATCH 09/22] Removed @SuppressWarnings --- src/main/java/rtg/util/Accessor.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/rtg/util/Accessor.java b/src/main/java/rtg/util/Accessor.java index e3724fcdc..3b5e8a038 100755 --- a/src/main/java/rtg/util/Accessor.java +++ b/src/main/java/rtg/util/Accessor.java @@ -58,7 +58,6 @@ private void setField(Class classObject) throws IllegalAccessException { throw new RuntimeException("None of " + Arrays.toString(fieldNames) + " found in class " + classObject.getName()); } - @SuppressWarnings("unused") public void setField(ObjectType object, FieldType fieldValue) { try { field(object).set(object, fieldValue); From f263f027ce62f6677c542f3d386b20e31fda7160 Mon Sep 17 00:00:00 2001 From: WhichOnesPink Date: Tue, 12 Jul 2016 14:10:31 +0100 Subject: [PATCH 10/22] Added 'receiveCanceled' to event handlers. Logging cancelled events ahead of snapshot release to test for other mods interfering with RTG event handlers. --- src/main/java/rtg/event/EventManagerRTG.java | 64 +++++++++++++------- 1 file changed, 43 insertions(+), 21 deletions(-) diff --git a/src/main/java/rtg/event/EventManagerRTG.java b/src/main/java/rtg/event/EventManagerRTG.java index a5d26588b..eb90610aa 100755 --- a/src/main/java/rtg/event/EventManagerRTG.java +++ b/src/main/java/rtg/event/EventManagerRTG.java @@ -4,9 +4,6 @@ import java.util.Random; import java.util.WeakHashMap; -import cpw.mods.fml.common.eventhandler.Event.Result; -import cpw.mods.fml.common.eventhandler.EventPriority; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.world.World; @@ -32,19 +29,22 @@ import rtg.world.gen.genlayer.RiverRemover; import rtg.world.gen.structure.MapGenScatteredFeatureRTG; import rtg.world.gen.structure.MapGenVillageRTG; +import cpw.mods.fml.common.eventhandler.Event; +import cpw.mods.fml.common.eventhandler.Event.Result; +import cpw.mods.fml.common.eventhandler.EventPriority; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; -@SuppressWarnings({"WeakerAccess","unused"}) public class EventManagerRTG { - private final LoadChunkRTG LOAD_CHUNK_RTG = new LoadChunkRTG(); - private final GenerateOreRTG GENERATE_ORE_RTG = new GenerateOreRTG(); - private final InitBiomeGensRTG INIT_BIOME_GENS_RTG = new InitBiomeGensRTG(); - private final BiomeFeaturesRTG BIOME_FEATURES_RTG = new BiomeFeaturesRTG(); - private final CustomTreesRTG CUSTOM_TREES_RTG = new CustomTreesRTG(); + private final LoadChunkRTG LOAD_CHUNK_RTG = new LoadChunkRTG(); + private final GenerateOreRTG GENERATE_ORE_RTG = new GenerateOreRTG(); + private final InitBiomeGensRTG INIT_BIOME_GENS_RTG = new InitBiomeGensRTG(); + private final BiomeFeaturesRTG BIOME_FEATURES_RTG = new BiomeFeaturesRTG(); + private final CustomTreesRTG CUSTOM_TREES_RTG = new CustomTreesRTG(); - public final WorldEventsRTG DISPLAY_SEED_RTG = new WorldEventsRTG(); - public final RTGEventRegister RTG_EVENTS_ENABLER = new RTGEventRegister(); - public final RTGEventUnregister RTG_EVENTS_DISABLER = new RTGEventUnregister(); + public final WorldEventsRTG DISPLAY_SEED_RTG = new WorldEventsRTG(); + public final RTGEventRegister RTG_EVENTS_ENABLER = new RTGEventRegister(); + public final RTGEventUnregister RTG_EVENTS_DISABLER = new RTGEventUnregister(); private WeakHashMap> chunkLoadEvents = new WeakHashMap<>(); private RealisticBiomeBase biome = null; @@ -65,8 +65,10 @@ public class LoadChunkRTG Logger.debug("RTG Event System: Initialising LoadChunkRTG"); } - @SubscribeEvent + @SubscribeEvent(receiveCanceled = true) public void loadChunkRTG(ChunkEvent.Load event) { + if (event.isCanceled()) { RTG.eventMgr.logCancelledEvent(event); } + Acceptor acceptor = chunkLoadEvents.get(event.world.provider.dimensionId); if (acceptor != null) { acceptor.accept(event); @@ -80,8 +82,9 @@ public class GenerateOreRTG Logger.debug("RTG Event System: Initialising GenerateOresRTG"); } - @SubscribeEvent + @SubscribeEvent(receiveCanceled = true) public void onGenerateMinable(OreGenEvent.GenerateMinable event) { + if (event.isCanceled()) { RTG.eventMgr.logCancelledEvent(event); } switch (event.type) { @@ -110,6 +113,7 @@ public void onGenerateMinable(OreGenEvent.GenerateMinable event) { return; default: + return; } } } @@ -121,8 +125,9 @@ public class InitBiomeGensRTG Logger.debug("RTG Event System: Initialising InitBiomeGensRTG"); } - @SubscribeEvent + @SubscribeEvent(receiveCanceled = true) public void initBiomeGensRTG(WorldTypeEvent.InitBiomeGens event) { + if (event.isCanceled()) { RTG.eventMgr.logCancelledEvent(event); } if (event.newBiomeGens[0].getClass().getName().contains("GenLayerEB")) return; @@ -141,8 +146,9 @@ public class BiomeFeaturesRTG Logger.debug("RTG Event System: Initialising BiomeFeaturesRTG"); } - @SubscribeEvent(priority = EventPriority.LOW) + @SubscribeEvent(priority = EventPriority.LOW, receiveCanceled = true) public void doBiomeFeatures(InitMapGenEvent event) { + if (event.isCanceled()) { RTG.eventMgr.logCancelledEvent(event); } Logger.debug("event type = %s", event.type.toString()); Logger.debug("event originalGen = %s", event.originalGen.toString()); @@ -182,8 +188,10 @@ public class CustomTreesRTG Logger.debug("RTG Event System: Initialising CustomTreesRTG"); } - @SubscribeEvent + @SubscribeEvent(receiveCanceled = true) public void onSaplingGrowTree(SaplingGrowTreeEvent event) { + if (event.isCanceled()) { RTG.eventMgr.logCancelledEvent(event); } + // Are RTG saplings enabled? if (!ConfigRTG.enableRTGSaplings) { return; } @@ -282,8 +290,10 @@ public class WorldEventsRTG Logger.debug("RTG Event System: Initialising WorldEventsRTG"); } - @SubscribeEvent + @SubscribeEvent(receiveCanceled = true) public void logWorldSeed(WorldEvent.Load event) { + if (event.isCanceled()) { RTG.eventMgr.logCancelledEvent(event); } + // This event fires for each dimension loaded (and then one last time in which it returns 0?), // so initialise a field to 0 and set it to the world seed and only display it in the log once. if (WORLD_SEED != event.world.getSeed() && event.world.getSeed() != 0) { @@ -293,8 +303,10 @@ public void logWorldSeed(WorldEvent.Load event) { } } - @SubscribeEvent + @SubscribeEvent(receiveCanceled = true) public void resetWorldSeed(WorldEvent.Unload event) { + if (event.isCanceled()) { RTG.eventMgr.logCancelledEvent(event); } + // reset WORLD_SEED so that it logs on the next server start if the seed is the same as the last load. WORLD_SEED = 0; } @@ -306,8 +318,10 @@ public class RTGEventRegister Logger.debug("RTG Event System: Initialising RTGEventRegister"); } - @SubscribeEvent + @SubscribeEvent(receiveCanceled = true) public void registerRTGEventHandlers(WorldTypeEvent.InitBiomeGens event) { + if (event.isCanceled()) { RTG.eventMgr.logCancelledEvent(event); } + if (event.worldType instanceof WorldTypeRTG) { if (!REGISTERED) { Logger.info("Registering RTG's Terrain Event Handlers..."); @@ -327,8 +341,10 @@ public class RTGEventUnregister Logger.debug("RTG Event System: Initialising RTGEventUnregister"); } - @SubscribeEvent + @SubscribeEvent(receiveCanceled = true) public void unregisterRTGEventHandlers(WorldEvent.Unload event) { + if (event.isCanceled()) { RTG.eventMgr.logCancelledEvent(event); } + if (REGISTERED) { Logger.info("Unregistering RTG's Terrain Event Handlers..."); RTG.eventMgr.unRegisterEventHandlers(); @@ -358,4 +374,10 @@ public void unRegisterEventHandlers() { public void setDimensionChunkLoadEvent(int dimension, Acceptor action) { chunkLoadEvents.put(dimension, action); } + + public void logCancelledEvent(Event event) + { + // TODO: Chnage this from info() to debug() before release. + Logger.info("EVENT CANCELLED! (%s) One of the following listeners cancelled the event: %s", event.toString(), event.getListenerList().toString()); + } } From cbc148503775c972b6599e78b95b9a18af8999db Mon Sep 17 00:00:00 2001 From: WhichOnesPink Date: Tue, 12 Jul 2016 20:56:07 +0100 Subject: [PATCH 11/22] Removed 'receiveCanceled' & minor refactoring. None of the events that RTG subscribes to are cancellable so 'receiveCanceled' was pointless. Also, the minor refactoring was mostly so that I could get my head into the new system as the new handler names, whilst totally fine, were making it difficult for me to see what was going on, as I was so used to the other naming convention. (Sorry @srs-bsns !!!) --- src/main/java/rtg/event/EventManagerRTG.java | 142 +++++++++---------- 1 file changed, 64 insertions(+), 78 deletions(-) diff --git a/src/main/java/rtg/event/EventManagerRTG.java b/src/main/java/rtg/event/EventManagerRTG.java index fe2d3d962..383e505c5 100755 --- a/src/main/java/rtg/event/EventManagerRTG.java +++ b/src/main/java/rtg/event/EventManagerRTG.java @@ -29,7 +29,6 @@ import rtg.world.gen.genlayer.RiverRemover; import rtg.world.gen.structure.MapGenScatteredFeatureRTG; import rtg.world.gen.structure.MapGenVillageRTG; -import cpw.mods.fml.common.eventhandler.Event; import cpw.mods.fml.common.eventhandler.Event.Result; import cpw.mods.fml.common.eventhandler.EventPriority; import cpw.mods.fml.common.eventhandler.SubscribeEvent; @@ -37,36 +36,34 @@ public class EventManagerRTG { private final LoadChunkRTG LOAD_CHUNK_RTG = new LoadChunkRTG(); - private final GenerateOreRTG GENERATE_ORE_RTG = new GenerateOreRTG(); + private final GenerateMinableRTG GENERATE_MINABLE_RTG = new GenerateMinableRTG(); private final InitBiomeGensRTG INIT_BIOME_GENS_RTG = new InitBiomeGensRTG(); - private final BiomeFeaturesRTG BIOME_FEATURES_RTG = new BiomeFeaturesRTG(); - private final CustomTreesRTG CUSTOM_TREES_RTG = new CustomTreesRTG(); - - public final WorldEventsRTG DISPLAY_SEED_RTG = new WorldEventsRTG(); - public final RTGEventRegister RTG_EVENTS_ENABLER = new RTGEventRegister(); + private final InitMapGenRTG INIT_MAP_GEN_RTG = new InitMapGenRTG(); + private final SaplingGrowTreeRTG SAPLING_GROW_TREE_RTG = new SaplingGrowTreeRTG(); + + public final WorldEventRTG WORLD_EVENT_RTG = new WorldEventRTG(); + public final RTGEventRegister RTG_EVENT_REGISTER = new RTGEventRegister(); private WeakHashMap> chunkLoadEvents = new WeakHashMap<>(); - private RealisticBiomeBase biome = null; - private boolean REGISTERED = false; - private long WORLD_SEED; + private boolean registered = false; + private long worldSeed; + private final String EVENT_SYSTEM = "RTG Event System: "; public EventManagerRTG() { // These should be registered once, and stay registered -srs - MinecraftForge.TERRAIN_GEN_BUS.register(RTG_EVENTS_ENABLER); - MinecraftForge.EVENT_BUS.register(DISPLAY_SEED_RTG); - Logger.info("RTG EventManager Initialised"); + MinecraftForge.TERRAIN_GEN_BUS.register(RTG_EVENT_REGISTER); + MinecraftForge.EVENT_BUS.register(WORLD_EVENT_RTG); + Logger.info(EVENT_SYSTEM + "Initialising EventManagerRTG"); } public class LoadChunkRTG { LoadChunkRTG() { - Logger.debug("RTG Event System: Initialising LoadChunkRTG"); + Logger.debug(EVENT_SYSTEM + "Initialising LoadChunkRTG"); } - @SubscribeEvent(receiveCanceled = true) + @SubscribeEvent public void loadChunkRTG(ChunkEvent.Load event) { - if (event.isCanceled()) { RTG.eventMgr.logCancelledEvent(event); } - Acceptor acceptor = chunkLoadEvents.get(event.world.provider.dimensionId); if (acceptor != null) { acceptor.accept(event); @@ -74,15 +71,14 @@ public void loadChunkRTG(ChunkEvent.Load event) { } } - public class GenerateOreRTG + public class GenerateMinableRTG { - GenerateOreRTG() { - Logger.debug("RTG Event System: Initialising GenerateOresRTG"); + GenerateMinableRTG() { + Logger.debug(EVENT_SYSTEM + "Initialising GenerateMinableRTG"); } - @SubscribeEvent(receiveCanceled = true) - public void onGenerateMinable(OreGenEvent.GenerateMinable event) { - if (event.isCanceled()) { RTG.eventMgr.logCancelledEvent(event); } + @SubscribeEvent + public void generateMinableRTG(OreGenEvent.GenerateMinable event) { switch (event.type) { @@ -120,12 +116,11 @@ public class InitBiomeGensRTG { InitBiomeGensRTG() { - Logger.debug("RTG Event System: Initialising InitBiomeGensRTG"); + Logger.debug(EVENT_SYSTEM + "Initialising InitBiomeGensRTG"); } - @SubscribeEvent(receiveCanceled = true) + @SubscribeEvent public void initBiomeGensRTG(WorldTypeEvent.InitBiomeGens event) { - if (event.isCanceled()) { RTG.eventMgr.logCancelledEvent(event); } if (event.newBiomeGens[0].getClass().getName().contains("GenLayerEB")) return; @@ -138,15 +133,14 @@ public void initBiomeGensRTG(WorldTypeEvent.InitBiomeGens event) { } } - public class BiomeFeaturesRTG + public class InitMapGenRTG { - BiomeFeaturesRTG() { - Logger.debug("RTG Event System: Initialising BiomeFeaturesRTG"); + InitMapGenRTG() { + Logger.debug(EVENT_SYSTEM + "Initialising InitMapGenRTG"); } - @SubscribeEvent(priority = EventPriority.LOW, receiveCanceled = true) - public void doBiomeFeatures(InitMapGenEvent event) { - if (event.isCanceled()) { RTG.eventMgr.logCancelledEvent(event); } + @SubscribeEvent(priority = EventPriority.LOW) + public void initMapGenRTG(InitMapGenEvent event) { Logger.debug("event type = %s", event.type.toString()); Logger.debug("event originalGen = %s", event.originalGen.toString()); @@ -175,20 +169,21 @@ public void doBiomeFeatures(InitMapGenEvent event) { break; default: + break; } + Logger.debug("event newGen = %s", event.newGen.toString()); } } - public class CustomTreesRTG + public class SaplingGrowTreeRTG { - CustomTreesRTG() { - Logger.debug("RTG Event System: Initialising CustomTreesRTG"); + SaplingGrowTreeRTG() { + Logger.debug(EVENT_SYSTEM + "Initialising SaplingGrowTreeRTG"); } - @SubscribeEvent(receiveCanceled = true) - public void onSaplingGrowTree(SaplingGrowTreeEvent event) { - if (event.isCanceled()) { RTG.eventMgr.logCancelledEvent(event); } + @SubscribeEvent + public void saplingGrowTreeRTG(SaplingGrowTreeEvent event) { // Are RTG saplings enabled? if (!ConfigRTG.enableRTGSaplings) { return; } @@ -282,73 +277,70 @@ public void onSaplingGrowTree(SaplingGrowTreeEvent event) { } } - public class WorldEventsRTG + public class WorldEventRTG { - WorldEventsRTG() { - Logger.debug("RTG Event System: Initialising WorldEventsRTG"); + WorldEventRTG() { + Logger.debug(EVENT_SYSTEM + "Initialising WorldEventRTG"); } - @SubscribeEvent(receiveCanceled = true) - public void logWorldSeed(WorldEvent.Load event) { - if (event.isCanceled()) { RTG.eventMgr.logCancelledEvent(event); } + @SubscribeEvent + public void onWorldLoad(WorldEvent.Load event) { // This event fires for each dimension loaded (and then one last time in which it returns 0?), // so initialise a field to 0 and set it to the world seed and only display it in the log once. - if (WORLD_SEED != event.world.getSeed() && event.world.getSeed() != 0) { + if (worldSeed != event.world.getSeed() && event.world.getSeed() != 0) { - WORLD_SEED = event.world.getSeed(); - Logger.info("World Seed: " + WORLD_SEED); + worldSeed = event.world.getSeed(); + Logger.info("World Seed: " + worldSeed); } } - @SubscribeEvent(receiveCanceled = true) - public void resetWorldSeed(WorldEvent.Unload event) { - if (event.isCanceled()) { RTG.eventMgr.logCancelledEvent(event); } + @SubscribeEvent + public void onWorldUnload(WorldEvent.Unload event) { - // reset WORLD_SEED so that it logs on the next server start if the seed is the same as the last load. - WORLD_SEED = 0; + // Reset WORLD_SEED so that it logs on the next server start if the seed is the same as the last load. + worldSeed = 0; } } public class RTGEventRegister { RTGEventRegister() { - Logger.debug("RTG Event System: Initialising RTGEventRegister"); + Logger.debug(EVENT_SYSTEM + "Initialising RTGEventRegister"); } - @SubscribeEvent(receiveCanceled = true) + @SubscribeEvent public void registerRTGEventHandlers(WorldTypeEvent.InitBiomeGens event) { - if (event.isCanceled()) { RTG.eventMgr.logCancelledEvent(event); } if (event.worldType instanceof WorldTypeRTG) { - if (!REGISTERED) { - Logger.info("Registering RTG's Terrain Event Handlers..."); + if (!registered) { + Logger.info(EVENT_SYSTEM + "Registering RTG's Terrain Event Handlers..."); RTG.eventMgr.registerEventHandlers(); - if (REGISTERED) Logger.info("RTG's Terrain Event Handlers have been registered successfully."); + if (registered) Logger.info(EVENT_SYSTEM + "RTG's Terrain Event Handlers have been registered successfully."); } } else { - if (REGISTERED) RTG.eventMgr.unRegisterEventHandlers(); + if (registered) RTG.eventMgr.unRegisterEventHandlers(); } } } public void registerEventHandlers() { - MinecraftForge.EVENT_BUS .register(LOAD_CHUNK_RTG); - MinecraftForge.ORE_GEN_BUS .register(GENERATE_ORE_RTG); - MinecraftForge.TERRAIN_GEN_BUS .register(INIT_BIOME_GENS_RTG); - MinecraftForge.TERRAIN_GEN_BUS .register(BIOME_FEATURES_RTG); - MinecraftForge.TERRAIN_GEN_BUS .register(CUSTOM_TREES_RTG); - REGISTERED = true; + MinecraftForge.EVENT_BUS.register(LOAD_CHUNK_RTG); + MinecraftForge.ORE_GEN_BUS.register(GENERATE_MINABLE_RTG); + MinecraftForge.TERRAIN_GEN_BUS.register(INIT_BIOME_GENS_RTG); + MinecraftForge.TERRAIN_GEN_BUS.register(INIT_MAP_GEN_RTG); + MinecraftForge.TERRAIN_GEN_BUS.register(SAPLING_GROW_TREE_RTG); + registered = true; } public void unRegisterEventHandlers() { - MinecraftForge.EVENT_BUS .unregister(LOAD_CHUNK_RTG); - MinecraftForge.ORE_GEN_BUS .unregister(GENERATE_ORE_RTG); - MinecraftForge.TERRAIN_GEN_BUS .unregister(INIT_BIOME_GENS_RTG); - MinecraftForge.TERRAIN_GEN_BUS .unregister(BIOME_FEATURES_RTG); - MinecraftForge.TERRAIN_GEN_BUS .unregister(CUSTOM_TREES_RTG); - REGISTERED = false; + MinecraftForge.EVENT_BUS.unregister(LOAD_CHUNK_RTG); + MinecraftForge.ORE_GEN_BUS.unregister(GENERATE_MINABLE_RTG); + MinecraftForge.TERRAIN_GEN_BUS.unregister(INIT_BIOME_GENS_RTG); + MinecraftForge.TERRAIN_GEN_BUS.unregister(INIT_MAP_GEN_RTG); + MinecraftForge.TERRAIN_GEN_BUS.unregister(SAPLING_GROW_TREE_RTG); + registered = false; } public void setDimensionChunkLoadEvent(int dimension, Acceptor action) { @@ -356,12 +348,6 @@ public void setDimensionChunkLoadEvent(int dimension, Acceptor } public boolean isRegistered() { - return REGISTERED; - } - - public void logCancelledEvent(Event event) - { - // TODO: Chnage this from info() to debug() before release. - Logger.info("EVENT CANCELLED! (%s) One of the following listeners cancelled the event: %s", event.toString(), event.getListenerList().toString()); + return registered; } } \ No newline at end of file From b0dbea78ba46409401af8ce335d2ca82ad960004 Mon Sep 17 00:00:00 2001 From: WhichOnesPink Date: Tue, 12 Jul 2016 21:28:06 +0100 Subject: [PATCH 12/22] Bumped to 1.1.0-snapshot-1 --- build.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.properties b/build.properties index d2d5279a3..43957c67c 100644 --- a/build.properties +++ b/build.properties @@ -4,7 +4,7 @@ mod_id=RTG mod_name=Realistic Terrain Generation mod_desc=Adds a new world type which generates realistic terrain for Overworld biomes. -mod_version=1.0.2 +mod_version=1.1.0-snapshot-1 mc_version=1.7.10 mod_url=https://github.com/Team-RTG/Realistic-Terrain-Generation mod_author="Team RTG" From 9d222434bc533167b852a5d4ec60d3fb3da25a14 Mon Sep 17 00:00:00 2001 From: WhichOnesPink Date: Tue, 12 Jul 2016 21:57:47 +0100 Subject: [PATCH 13/22] WorldGenCacti honours soilBlock & soilMeta. Also removed unused constructors. --- .../rtg/world/gen/feature/WorldGenCacti.java | 23 ++++++------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/src/main/java/rtg/world/gen/feature/WorldGenCacti.java b/src/main/java/rtg/world/gen/feature/WorldGenCacti.java index 0ca4469af..1c086ddee 100755 --- a/src/main/java/rtg/world/gen/feature/WorldGenCacti.java +++ b/src/main/java/rtg/world/gen/feature/WorldGenCacti.java @@ -9,24 +9,15 @@ public class WorldGenCacti extends WorldGenerator { - private boolean sand; - private int eHeight; + private boolean sandOnly; + private int extraHeight; private Block soilBlock; private byte soilMeta; - public WorldGenCacti(boolean sandOnly) - { - this(sandOnly, 0); - } - - public WorldGenCacti(boolean sandOnly, int extraHeight) { - this(sandOnly, extraHeight, Blocks.sand, (byte)0); - } - public WorldGenCacti(boolean sandOnly, int extraHeight, Block soilBlock, byte soilMeta) { - sand = sandOnly; - eHeight = extraHeight; + this.sandOnly = sandOnly; + this.extraHeight = extraHeight; this.soilBlock = soilBlock; this.soilMeta = soilMeta; } @@ -43,15 +34,15 @@ public boolean generate(World world, Random rand, int x, int y, int z) if (world.isAirBlock(i1, j1, k1)) { b = world.getBlock(i1, j1 - 1, k1); - if(b == Blocks.sand || (!sand && (b == Blocks.grass || b == Blocks.dirt))) + if(b == Blocks.sand || (!sandOnly && (b == Blocks.grass || b == Blocks.dirt))) { int l1 = 1 + rand.nextInt(rand.nextInt(3) + 1); if(b == Blocks.grass || b == Blocks.dirt) { - world.setBlock(i1, j1 - 1, k1, Blocks.sand, 0, 2); + world.setBlock(i1, j1 - 1, k1, this.soilBlock, this.soilMeta, 2); } - for (int i2 = 0; i2 < l1 + eHeight; ++i2) + for (int i2 = 0; i2 < l1 + extraHeight; ++i2) { if (Blocks.cactus.canBlockStay(world, i1, j1 + i2, k1)) { From 89b589a0b12db765289a5157ff20339b5df0395a Mon Sep 17 00:00:00 2001 From: WhichOnesPink Date: Sat, 23 Jul 2016 14:47:16 +0100 Subject: [PATCH 14/22] Bumped to 1.1.0 --- build.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.properties b/build.properties index 43957c67c..72f89c1cc 100644 --- a/build.properties +++ b/build.properties @@ -4,7 +4,7 @@ mod_id=RTG mod_name=Realistic Terrain Generation mod_desc=Adds a new world type which generates realistic terrain for Overworld biomes. -mod_version=1.1.0-snapshot-1 +mod_version=1.1.0 mc_version=1.7.10 mod_url=https://github.com/Team-RTG/Realistic-Terrain-Generation mod_author="Team RTG" From fad80ce5f5e2980e2e416da4d754b5329eea034b Mon Sep 17 00:00:00 2001 From: WhichOnesPink Date: Sat, 23 Jul 2016 17:06:01 +0100 Subject: [PATCH 15/22] Added biome support for Flowercraft. --- build.properties | 41 +- src/main/java/rtg/RTG.java | 6 +- .../flowercraft/config/BiomeConfigFC.java | 17 + .../flowercraft/config/BiomeConfigFCBase.java | 10 + .../config/BiomeConfigFCPhantasia.java | 8 + .../java/rtg/config/BiomeConfigManager.java | 370 +----------------- src/main/java/rtg/config/ConfigManager.java | 8 +- .../java/rtg/config/flowercraft/ConfigFC.java | 37 ++ .../flowercraft/RealisticBiomeFCBase.java | 47 +++ .../RealisticBiomeFCPhantasia.java | 23 ++ .../surface/flowercraft/SurfaceFCBase.java | 13 + .../flowercraft/SurfaceFCPhantasia.java | 59 +++ .../flowercraft/TerrainFCPhantasia.java | 21 + 13 files changed, 287 insertions(+), 373 deletions(-) create mode 100644 src/main/java/rtg/api/biome/flowercraft/config/BiomeConfigFC.java create mode 100644 src/main/java/rtg/api/biome/flowercraft/config/BiomeConfigFCBase.java create mode 100644 src/main/java/rtg/api/biome/flowercraft/config/BiomeConfigFCPhantasia.java create mode 100644 src/main/java/rtg/config/flowercraft/ConfigFC.java create mode 100644 src/main/java/rtg/world/biome/realistic/flowercraft/RealisticBiomeFCBase.java create mode 100644 src/main/java/rtg/world/biome/realistic/flowercraft/RealisticBiomeFCPhantasia.java create mode 100644 src/main/java/rtg/world/gen/surface/flowercraft/SurfaceFCBase.java create mode 100644 src/main/java/rtg/world/gen/surface/flowercraft/SurfaceFCPhantasia.java create mode 100644 src/main/java/rtg/world/gen/terrain/flowercraft/TerrainFCPhantasia.java diff --git a/build.properties b/build.properties index 72f89c1cc..c18ff2213 100644 --- a/build.properties +++ b/build.properties @@ -14,23 +14,24 @@ mcf_version=10.13.4.1558 run_dir=run package_base=org.teamrtg mod_deps=after:abyssalcraft@[1.9.1.2,);\ - after:arsmagica2@[1.4.0.008,);\ - after:ATG@[0.10.0,);\ - after:BiomesOPlenty@[2.1.0,);\ - after:BuildCraft|Core@[7.1.7,);\ - after:enhancedbiomes@2.5 for MC 1.7.10;\ - after:enviromine@[1.3.119,);\ - after:ExtrabiomesXL@[3.16.2,);\ - after:ForgottenNature@[1.6.11,);\ - after:Growthcraft|Bamboo@[1.7.10-2.5.0,);\ - after:Highlands@[2.2.3,);\ - after:ICMod@[1.5.0,);\ - after:lom@[1.7.10-3.2.0,);\ - after:Mariculture@[1.7.10-1.2.4.2a-5,);\ - after:mod_IDT;\ - after:Railcraft@[9.7.0.0,);\ - after:RidiculousWorld@[0.1,);\ - after:sushicraft@[14.4,);\ - after:Thaumcraft@[4.2.3.4,);\ - after:TofuCraft@2.1.6-MC1.7.10;\ - after:vampirism@[0.7.8.5,) + after:arsmagica2@[1.4.0.008,);\ + after:ATG@[0.10.0,);\ + after:BiomesOPlenty@[2.1.0,);\ + after:BuildCraft|Core@[7.1.7,);\ + after:enhancedbiomes@2.5 for MC 1.7.10;\ + after:enviromine@[1.3.119,);\ + after:ExtrabiomesXL@[3.16.2,);\ + after:flowercraftmod@[1.9,);\ + after:ForgottenNature@[1.6.11,);\ + after:Growthcraft|Bamboo@[1.7.10-2.5.0,);\ + after:Highlands@[2.2.3,);\ + after:ICMod@[1.5.0,);\ + after:lom@[1.7.10-3.2.0,);\ + after:Mariculture@[1.7.10-1.2.4.2a-5,);\ + after:mod_IDT;\ + after:Railcraft@[9.7.0.0,);\ + after:RidiculousWorld@[0.1,);\ + after:sushicraft@[14.4,);\ + after:Thaumcraft@[4.2.3.4,);\ + after:TofuCraft@2.1.6-MC1.7.10;\ + after:vampirism@[0.7.8.5,) diff --git a/src/main/java/rtg/RTG.java b/src/main/java/rtg/RTG.java index 31baf96e3..daa05b308 100755 --- a/src/main/java/rtg/RTG.java +++ b/src/main/java/rtg/RTG.java @@ -1,7 +1,5 @@ package rtg; -import java.util.ArrayList; - import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.Mod.Instance; @@ -26,6 +24,7 @@ import rtg.world.biome.realistic.chromaticraft.RealisticBiomeCCBase; import rtg.world.biome.realistic.enhancedbiomes.RealisticBiomeEBBase; import rtg.world.biome.realistic.extrabiomes.RealisticBiomeEBXLBase; +import rtg.world.biome.realistic.flowercraft.RealisticBiomeFCBase; import rtg.world.biome.realistic.forgottennature.RealisticBiomeFNBase; import rtg.world.biome.realistic.growthcraft.RealisticBiomeGCBase; import rtg.world.biome.realistic.highlands.RealisticBiomeHLBase; @@ -40,6 +39,8 @@ import rtg.world.gen.structure.MapGenScatteredFeatureRTG; import rtg.world.gen.structure.MapGenVillageRTG; +import java.util.ArrayList; + //@Mod(modid = "RTG", name = "Realistic Terrain Generaton", version = "0.8.0d", dependencies = "required-after:Forge@[10.13.4.1448,)", acceptableRemoteVersions = "*") @Mod(modid = ModInfo.MOD_ID, name = ModInfo.MOD_NAME, version = ModInfo.MOD_VERSION, dependencies = "required-after:Forge@[" + ModInfo.FORGE_DEP + ",)" + ModInfo.MOD_DEPS, acceptableRemoteVersions = "*") @@ -107,6 +108,7 @@ public void postInit(FMLPostInitializationEvent event) RealisticBiomeFNBase.addBiomes(); RealisticBiomeICBase.addBiomes(); RealisticBiomeIDTBase.addBiomes(); + RealisticBiomeFCBase.addBiomes(); RealisticBiomePresenceTester.doBiomeCheck(); } diff --git a/src/main/java/rtg/api/biome/flowercraft/config/BiomeConfigFC.java b/src/main/java/rtg/api/biome/flowercraft/config/BiomeConfigFC.java new file mode 100644 index 000000000..809713658 --- /dev/null +++ b/src/main/java/rtg/api/biome/flowercraft/config/BiomeConfigFC.java @@ -0,0 +1,17 @@ +package rtg.api.biome.flowercraft.config; + +import rtg.api.biome.BiomeConfig; + +public class BiomeConfigFC { + + public static BiomeConfig biomeConfigFCPhantasia; + + public static BiomeConfig[] getBiomeConfigs() { + + BiomeConfig[] biomeConfigs = new BiomeConfig[]{ + biomeConfigFCPhantasia + }; + + return biomeConfigs; + } +} diff --git a/src/main/java/rtg/api/biome/flowercraft/config/BiomeConfigFCBase.java b/src/main/java/rtg/api/biome/flowercraft/config/BiomeConfigFCBase.java new file mode 100644 index 000000000..115a159f9 --- /dev/null +++ b/src/main/java/rtg/api/biome/flowercraft/config/BiomeConfigFCBase.java @@ -0,0 +1,10 @@ +package rtg.api.biome.flowercraft.config; + +import rtg.api.biome.BiomeConfig; + +public class BiomeConfigFCBase extends BiomeConfig { + + public BiomeConfigFCBase(String biomeSlug) { + super("flowercraft", biomeSlug); + } +} diff --git a/src/main/java/rtg/api/biome/flowercraft/config/BiomeConfigFCPhantasia.java b/src/main/java/rtg/api/biome/flowercraft/config/BiomeConfigFCPhantasia.java new file mode 100644 index 000000000..f780cf0f0 --- /dev/null +++ b/src/main/java/rtg/api/biome/flowercraft/config/BiomeConfigFCPhantasia.java @@ -0,0 +1,8 @@ +package rtg.api.biome.flowercraft.config; + + +public class BiomeConfigFCPhantasia extends BiomeConfigFCBase { + public BiomeConfigFCPhantasia() { + super("phantasia"); + } +} diff --git a/src/main/java/rtg/config/BiomeConfigManager.java b/src/main/java/rtg/config/BiomeConfigManager.java index cc29ebbde..ed4221332 100644 --- a/src/main/java/rtg/config/BiomeConfigManager.java +++ b/src/main/java/rtg/config/BiomeConfigManager.java @@ -1,288 +1,27 @@ package rtg.config; -import java.util.ArrayList; - import net.minecraftforge.common.config.Configuration; import rtg.api.biome.BiomeConfig; import rtg.api.biome.BiomeConfigProperty; -import rtg.api.biome.abyssalcraft.config.BiomeConfigAC; -import rtg.api.biome.abyssalcraft.config.BiomeConfigACCoraliumInfestedSwamp; -import rtg.api.biome.abyssalcraft.config.BiomeConfigACDarklands; -import rtg.api.biome.abyssalcraft.config.BiomeConfigACDarklandsForest; -import rtg.api.biome.abyssalcraft.config.BiomeConfigACDarklandsHighland; -import rtg.api.biome.abyssalcraft.config.BiomeConfigACDarklandsMountains; -import rtg.api.biome.abyssalcraft.config.BiomeConfigACDarklandsPlains; +import rtg.api.biome.abyssalcraft.config.*; import rtg.api.biome.arsmagica.config.BiomeConfigAM; import rtg.api.biome.arsmagica.config.BiomeConfigAMWitchwoodForest; -import rtg.api.biome.atg.config.BiomeConfigATG; -import rtg.api.biome.atg.config.BiomeConfigATGGravelBeach; -import rtg.api.biome.atg.config.BiomeConfigATGRockySteppe; -import rtg.api.biome.atg.config.BiomeConfigATGShrubland; -import rtg.api.biome.atg.config.BiomeConfigATGSnowyGravelBeach; -import rtg.api.biome.atg.config.BiomeConfigATGTropicalShrubland; -import rtg.api.biome.atg.config.BiomeConfigATGTundra; -import rtg.api.biome.atg.config.BiomeConfigATGVolcano; -import rtg.api.biome.atg.config.BiomeConfigATGWoodland; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOP; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPAlps; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPAlpsForest; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPArctic; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPBambooForest; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPBayou; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPBog; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPBorealForest; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPBrushland; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPCanyon; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPCanyonRavine; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPChaparral; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPCherryBlossomGrove; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPConiferousForest; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPCoralReef; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPCrag; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPDeadForest; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPDeadSwamp; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPDeciduousForest; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPDenseForest; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPDryRiver; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPEucalyptusForest; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPFen; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPFlowerField; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPFrostForest; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPFungiForest; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPGarden; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPGlacier; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPGrassland; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPGrove; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPHeathland; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPHighland; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPJadeCliffs; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPKelpForest; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPLandOfLakes; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPLandOfLakesMarsh; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPLavenderFields; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPLushDesert; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPLushRiver; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPLushSwamp; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPMangrove; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPMapleWoods; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPMarsh; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPMeadow; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPMeadowForest; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPMoor; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPMountain; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPMysticGrove; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPOasis; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPOminousWoods; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPOrchard; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPOriginValley; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPOutback; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPPrairie; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPQuagmire; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPRainforest; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPRedwoodForest; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPSacredSprings; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPScrubland; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPSeasonalForest; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPSeasonalForestClearing; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPShield; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPShrubland; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPSilkglades; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPSludgepit; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPSnowyConiferousForest; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPSpruceWoods; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPSteppe; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPTemperateRainforest; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPThicket; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPTropicalRainforest; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPTropics; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPTundra; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPVolcano; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPWasteland; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPWetland; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPWoodland; -import rtg.api.biome.biomesoplenty.config.BiomeConfigBOPXericShrubland; +import rtg.api.biome.atg.config.*; +import rtg.api.biome.biomesoplenty.config.*; import rtg.api.biome.buildcraft.config.BiomeConfigBC; import rtg.api.biome.buildcraft.config.BiomeConfigBCDesertOilField; import rtg.api.biome.buildcraft.config.BiomeConfigBCOceanOilField; import rtg.api.biome.chromaticraft.config.BiomeConfigCC; import rtg.api.biome.chromaticraft.config.BiomeConfigCCEnderForest; import rtg.api.biome.chromaticraft.config.BiomeConfigCCRainbowForest; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEB; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBAlpineMountains; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBAlpineMountainsEdge; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBAlpineMountainsM; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBAlpineTundra; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBAspenForest; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBAspenHills; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBBadlands; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBBasin; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBBlossomHills; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBBlossomWoods; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBBorealArchipelago; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBBorealForest; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBBorealPlateau; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBBorealPlateauM; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBCarr; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBClayHills; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBClearing; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBColdBorealForest; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBColdCypressForest; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBColdFirForest; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBColdPineForest; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBCreekBed; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBCypressForest; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBDesertArchipelago; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBEphemeralLake; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBEphemeralLakeEdge; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBFens; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBFirForest; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBFloweryArchipelago; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBForestedArchipelago; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBForestedMountains; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBForestedValley; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBFrozenArchipelago; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBGlacier; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBGrassyArchipelago; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBIceSheet; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBKakadu; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBLake; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBLowHills; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBMangroves; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBMarsh; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBMeadow; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBMeadowM; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBMountainousArchipelago; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBMountains; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBMountainsEdge; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBOakForest; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBOasis; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBPineForest; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBPineForestArchipelago; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBPlateau; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBPolarDesert; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBPrairie; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBRainforest; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBRainforestValley; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBRedDesert; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBRiparianZone; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBRockyDesert; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBRockyHills; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBRoofedShrublands; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBSahara; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBSandstoneCanyon; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBSandstoneCanyon2; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBSandstoneRanges; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBSandstoneRangesM; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBScree; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBScrub; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBShield; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBShrublands; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBSilverPineForest; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBSilverPineHills; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBSnowyDesert; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBSnowyPlateau; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBSnowyRanges; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBSnowyWastelands; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBSteppe; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBStoneCanyon; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBStoneCanyon2; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBTropicalArchipelago; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBTundra; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBVolcano; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBVolcanoM; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBWastelands; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBWoodlandField; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBWoodlandHills; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBWoodlandLake; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBWoodlandLakeEdge; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBWoodlands; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBXericSavanna; -import rtg.api.biome.enhancedbiomes.config.BiomeConfigEBXericShrubland; -import rtg.api.biome.extrabiomes.config.BiomeConfigEBXL; -import rtg.api.biome.extrabiomes.config.BiomeConfigEBXLAlpine; -import rtg.api.biome.extrabiomes.config.BiomeConfigEBXLAutumnWoods; -import rtg.api.biome.extrabiomes.config.BiomeConfigEBXLBirchForest; -import rtg.api.biome.extrabiomes.config.BiomeConfigEBXLExtremeJungle; -import rtg.api.biome.extrabiomes.config.BiomeConfigEBXLForestedHills; -import rtg.api.biome.extrabiomes.config.BiomeConfigEBXLForestedIsland; -import rtg.api.biome.extrabiomes.config.BiomeConfigEBXLGlacier; -import rtg.api.biome.extrabiomes.config.BiomeConfigEBXLGreenHills; -import rtg.api.biome.extrabiomes.config.BiomeConfigEBXLGreenSwamp; -import rtg.api.biome.extrabiomes.config.BiomeConfigEBXLIceWasteland; -import rtg.api.biome.extrabiomes.config.BiomeConfigEBXLMarsh; -import rtg.api.biome.extrabiomes.config.BiomeConfigEBXLMeadow; -import rtg.api.biome.extrabiomes.config.BiomeConfigEBXLMiniJungle; -import rtg.api.biome.extrabiomes.config.BiomeConfigEBXLMountainDesert; -import rtg.api.biome.extrabiomes.config.BiomeConfigEBXLMountainRidge; -import rtg.api.biome.extrabiomes.config.BiomeConfigEBXLMountainTaiga; -import rtg.api.biome.extrabiomes.config.BiomeConfigEBXLPineForest; -import rtg.api.biome.extrabiomes.config.BiomeConfigEBXLRainforest; -import rtg.api.biome.extrabiomes.config.BiomeConfigEBXLRedwoodForest; -import rtg.api.biome.extrabiomes.config.BiomeConfigEBXLRedwoodLush; -import rtg.api.biome.extrabiomes.config.BiomeConfigEBXLSavanna; -import rtg.api.biome.extrabiomes.config.BiomeConfigEBXLShrubland; -import rtg.api.biome.extrabiomes.config.BiomeConfigEBXLSnowForest; -import rtg.api.biome.extrabiomes.config.BiomeConfigEBXLSnowyRainforest; -import rtg.api.biome.extrabiomes.config.BiomeConfigEBXLTemperateRainforest; -import rtg.api.biome.extrabiomes.config.BiomeConfigEBXLTundra; -import rtg.api.biome.extrabiomes.config.BiomeConfigEBXLWasteland; -import rtg.api.biome.extrabiomes.config.BiomeConfigEBXLWoodlands; -import rtg.api.biome.forgottennature.config.BiomeConfigFN; -import rtg.api.biome.forgottennature.config.BiomeConfigFNCherryBlossomWoodland; -import rtg.api.biome.forgottennature.config.BiomeConfigFNCrystalForest; -import rtg.api.biome.forgottennature.config.BiomeConfigFNEucalyptusForest; -import rtg.api.biome.forgottennature.config.BiomeConfigFNGreatwoodForest; -import rtg.api.biome.forgottennature.config.BiomeConfigFNMapleForest; -import rtg.api.biome.forgottennature.config.BiomeConfigFNRedwoodForest; -import rtg.api.biome.forgottennature.config.BiomeConfigFNRedwoodForestHills; -import rtg.api.biome.forgottennature.config.BiomeConfigFNTropicalForest; -import rtg.api.biome.forgottennature.config.BiomeConfigFNTropicalForestHills; +import rtg.api.biome.enhancedbiomes.config.*; +import rtg.api.biome.extrabiomes.config.*; +import rtg.api.biome.flowercraft.config.BiomeConfigFC; +import rtg.api.biome.flowercraft.config.BiomeConfigFCPhantasia; +import rtg.api.biome.forgottennature.config.*; import rtg.api.biome.growthcraft.config.BiomeConfigGC; import rtg.api.biome.growthcraft.config.BiomeConfigGCBambooForest; -import rtg.api.biome.highlands.config.BiomeConfigHL; -import rtg.api.biome.highlands.config.BiomeConfigHLAlps; -import rtg.api.biome.highlands.config.BiomeConfigHLAutumnForest; -import rtg.api.biome.highlands.config.BiomeConfigHLBadlands; -import rtg.api.biome.highlands.config.BiomeConfigHLBaldHill; -import rtg.api.biome.highlands.config.BiomeConfigHLBirchHills; -import rtg.api.biome.highlands.config.BiomeConfigHLBog; -import rtg.api.biome.highlands.config.BiomeConfigHLCanyon; -import rtg.api.biome.highlands.config.BiomeConfigHLCliffs; -import rtg.api.biome.highlands.config.BiomeConfigHLDesertIsland; -import rtg.api.biome.highlands.config.BiomeConfigHLDesertMountains; -import rtg.api.biome.highlands.config.BiomeConfigHLDunes; -import rtg.api.biome.highlands.config.BiomeConfigHLEstuary; -import rtg.api.biome.highlands.config.BiomeConfigHLFlyingMountains; -import rtg.api.biome.highlands.config.BiomeConfigHLForestIsland; -import rtg.api.biome.highlands.config.BiomeConfigHLGlacier; -import rtg.api.biome.highlands.config.BiomeConfigHLHighlandsB; -import rtg.api.biome.highlands.config.BiomeConfigHLJungleIsland; -import rtg.api.biome.highlands.config.BiomeConfigHLLake; -import rtg.api.biome.highlands.config.BiomeConfigHLLowlands; -import rtg.api.biome.highlands.config.BiomeConfigHLMeadow; -import rtg.api.biome.highlands.config.BiomeConfigHLMesa; -import rtg.api.biome.highlands.config.BiomeConfigHLOasis; -import rtg.api.biome.highlands.config.BiomeConfigHLOutback; -import rtg.api.biome.highlands.config.BiomeConfigHLPinelands; -import rtg.api.biome.highlands.config.BiomeConfigHLRainforest; -import rtg.api.biome.highlands.config.BiomeConfigHLRedwoodForest; -import rtg.api.biome.highlands.config.BiomeConfigHLRockIsland; -import rtg.api.biome.highlands.config.BiomeConfigHLRockMountains; -import rtg.api.biome.highlands.config.BiomeConfigHLSahel; -import rtg.api.biome.highlands.config.BiomeConfigHLSavannah; -import rtg.api.biome.highlands.config.BiomeConfigHLShrubland; -import rtg.api.biome.highlands.config.BiomeConfigHLSnowIsland; -import rtg.api.biome.highlands.config.BiomeConfigHLSnowMountains; -import rtg.api.biome.highlands.config.BiomeConfigHLSteppe; -import rtg.api.biome.highlands.config.BiomeConfigHLTallPineForest; -import rtg.api.biome.highlands.config.BiomeConfigHLTropicalIslands; -import rtg.api.biome.highlands.config.BiomeConfigHLTropics; -import rtg.api.biome.highlands.config.BiomeConfigHLTundra; -import rtg.api.biome.highlands.config.BiomeConfigHLValley; -import rtg.api.biome.highlands.config.BiomeConfigHLVolcanoIsland; -import rtg.api.biome.highlands.config.BiomeConfigHLWindyIsland; -import rtg.api.biome.highlands.config.BiomeConfigHLWoodlands; -import rtg.api.biome.highlands.config.BiomeConfigHLWoodsMountains; +import rtg.api.biome.highlands.config.*; import rtg.api.biome.icmod.config.BiomeConfigIC; import rtg.api.biome.icmod.config.BiomeConfigICIceCream; import rtg.api.biome.idt.config.BiomeConfigIDT; @@ -292,90 +31,17 @@ import rtg.api.biome.lotsomobs.config.BiomeConfigLOM; import rtg.api.biome.lotsomobs.config.BiomeConfigLOMAntartica; import rtg.api.biome.lotsomobs.config.BiomeConfigLOMTropicalBeach; -import rtg.api.biome.ridiculousworld.config.BiomeConfigRW; -import rtg.api.biome.ridiculousworld.config.BiomeConfigRWBotanicalGarden; -import rtg.api.biome.ridiculousworld.config.BiomeConfigRWMountainOfMadness; -import rtg.api.biome.ridiculousworld.config.BiomeConfigRWMurica; -import rtg.api.biome.ridiculousworld.config.BiomeConfigRWOssuary; -import rtg.api.biome.ridiculousworld.config.BiomeConfigRWRockCandyMountain; -import rtg.api.biome.ridiculousworld.config.BiomeConfigRWShadowFen; -import rtg.api.biome.ridiculousworld.config.BiomeConfigRWSpookyForest; +import rtg.api.biome.ridiculousworld.config.*; import rtg.api.biome.thaumcraft.config.BiomeConfigTC; import rtg.api.biome.thaumcraft.config.BiomeConfigTCEerie; import rtg.api.biome.thaumcraft.config.BiomeConfigTCMagicalForest; import rtg.api.biome.thaumcraft.config.BiomeConfigTCTaintedLand; -import rtg.api.biome.tofucraft.config.BiomeConfigTOFU; -import rtg.api.biome.tofucraft.config.BiomeConfigTOFULeekPlains; -import rtg.api.biome.tofucraft.config.BiomeConfigTOFUTofuBuildings; -import rtg.api.biome.tofucraft.config.BiomeConfigTOFUTofuExtremeHills; -import rtg.api.biome.tofucraft.config.BiomeConfigTOFUTofuExtremeHillsEdge; -import rtg.api.biome.tofucraft.config.BiomeConfigTOFUTofuForest; -import rtg.api.biome.tofucraft.config.BiomeConfigTOFUTofuForestHills; -import rtg.api.biome.tofucraft.config.BiomeConfigTOFUTofuPlainHills; -import rtg.api.biome.tofucraft.config.BiomeConfigTOFUTofuPlains; -import rtg.api.biome.tofucraft.config.BiomeConfigTOFUTofuRiver; +import rtg.api.biome.tofucraft.config.*; import rtg.api.biome.vampirism.config.BiomeConfigVAMP; import rtg.api.biome.vampirism.config.BiomeConfigVAMPVampireForest; -import rtg.api.biome.vanilla.config.BiomeConfigVanilla; -import rtg.api.biome.vanilla.config.BiomeConfigVanillaBeach; -import rtg.api.biome.vanilla.config.BiomeConfigVanillaBirchForest; -import rtg.api.biome.vanilla.config.BiomeConfigVanillaBirchForestHills; -import rtg.api.biome.vanilla.config.BiomeConfigVanillaBirchForestHillsM; -import rtg.api.biome.vanilla.config.BiomeConfigVanillaBirchForestM; -import rtg.api.biome.vanilla.config.BiomeConfigVanillaColdBeach; -import rtg.api.biome.vanilla.config.BiomeConfigVanillaColdTaiga; -import rtg.api.biome.vanilla.config.BiomeConfigVanillaColdTaigaHills; -import rtg.api.biome.vanilla.config.BiomeConfigVanillaColdTaigaM; -import rtg.api.biome.vanilla.config.BiomeConfigVanillaDeepOcean; -import rtg.api.biome.vanilla.config.BiomeConfigVanillaDesert; -import rtg.api.biome.vanilla.config.BiomeConfigVanillaDesertHills; -import rtg.api.biome.vanilla.config.BiomeConfigVanillaDesertM; -import rtg.api.biome.vanilla.config.BiomeConfigVanillaExtremeHills; -import rtg.api.biome.vanilla.config.BiomeConfigVanillaExtremeHillsEdge; -import rtg.api.biome.vanilla.config.BiomeConfigVanillaExtremeHillsM; -import rtg.api.biome.vanilla.config.BiomeConfigVanillaExtremeHillsPlus; -import rtg.api.biome.vanilla.config.BiomeConfigVanillaExtremeHillsPlusM; -import rtg.api.biome.vanilla.config.BiomeConfigVanillaFlowerForest; -import rtg.api.biome.vanilla.config.BiomeConfigVanillaForest; -import rtg.api.biome.vanilla.config.BiomeConfigVanillaForestHills; -import rtg.api.biome.vanilla.config.BiomeConfigVanillaFrozenOcean; -import rtg.api.biome.vanilla.config.BiomeConfigVanillaFrozenRiver; -import rtg.api.biome.vanilla.config.BiomeConfigVanillaIceMountains; -import rtg.api.biome.vanilla.config.BiomeConfigVanillaIcePlains; -import rtg.api.biome.vanilla.config.BiomeConfigVanillaIcePlainsSpikes; -import rtg.api.biome.vanilla.config.BiomeConfigVanillaJungle; -import rtg.api.biome.vanilla.config.BiomeConfigVanillaJungleEdge; -import rtg.api.biome.vanilla.config.BiomeConfigVanillaJungleEdgeM; -import rtg.api.biome.vanilla.config.BiomeConfigVanillaJungleHills; -import rtg.api.biome.vanilla.config.BiomeConfigVanillaJungleM; -import rtg.api.biome.vanilla.config.BiomeConfigVanillaMegaSpruceTaiga; -import rtg.api.biome.vanilla.config.BiomeConfigVanillaMegaTaiga; -import rtg.api.biome.vanilla.config.BiomeConfigVanillaMegaTaigaHills; -import rtg.api.biome.vanilla.config.BiomeConfigVanillaMesa; -import rtg.api.biome.vanilla.config.BiomeConfigVanillaMesaBryce; -import rtg.api.biome.vanilla.config.BiomeConfigVanillaMesaPlateau; -import rtg.api.biome.vanilla.config.BiomeConfigVanillaMesaPlateauF; -import rtg.api.biome.vanilla.config.BiomeConfigVanillaMesaPlateauFM; -import rtg.api.biome.vanilla.config.BiomeConfigVanillaMesaPlateauM; -import rtg.api.biome.vanilla.config.BiomeConfigVanillaMushroomIsland; -import rtg.api.biome.vanilla.config.BiomeConfigVanillaMushroomIslandShore; -import rtg.api.biome.vanilla.config.BiomeConfigVanillaOcean; -import rtg.api.biome.vanilla.config.BiomeConfigVanillaPlains; -import rtg.api.biome.vanilla.config.BiomeConfigVanillaRedwoodTaigaHills; -import rtg.api.biome.vanilla.config.BiomeConfigVanillaRiver; -import rtg.api.biome.vanilla.config.BiomeConfigVanillaRoofedForest; -import rtg.api.biome.vanilla.config.BiomeConfigVanillaRoofedForestM; -import rtg.api.biome.vanilla.config.BiomeConfigVanillaSavanna; -import rtg.api.biome.vanilla.config.BiomeConfigVanillaSavannaM; -import rtg.api.biome.vanilla.config.BiomeConfigVanillaSavannaPlateau; -import rtg.api.biome.vanilla.config.BiomeConfigVanillaSavannaPlateauM; -import rtg.api.biome.vanilla.config.BiomeConfigVanillaStoneBeach; -import rtg.api.biome.vanilla.config.BiomeConfigVanillaSunflowerPlains; -import rtg.api.biome.vanilla.config.BiomeConfigVanillaSwampland; -import rtg.api.biome.vanilla.config.BiomeConfigVanillaSwamplandM; -import rtg.api.biome.vanilla.config.BiomeConfigVanillaTaiga; -import rtg.api.biome.vanilla.config.BiomeConfigVanillaTaigaHills; -import rtg.api.biome.vanilla.config.BiomeConfigVanillaTaigaM; +import rtg.api.biome.vanilla.config.*; + +import java.util.ArrayList; public class BiomeConfigManager { @@ -400,6 +66,7 @@ public static void initBiomeConfigs() initBiomeConfigsLOM(); initBiomeConfigsTOFU(); initBiomeConfigsFN(); + initBiomeConfigsFC(); initBiomeConfigsVanilla(); } @@ -648,11 +315,16 @@ public static void initBiomeConfigsEBXL() BiomeConfigEBXL.biomeConfigEBXLWasteland = new BiomeConfigEBXLWasteland(); BiomeConfigEBXL.biomeConfigEBXLWoodlands = new BiomeConfigEBXLWoodlands(); } - + public static void initBiomeConfigsGC() { BiomeConfigGC.biomeConfigGCBambooForest = new BiomeConfigGCBambooForest(); } + + public static void initBiomeConfigsFC() + { + BiomeConfigFC.biomeConfigFCPhantasia = new BiomeConfigFCPhantasia(); + } public static void initBiomeConfigsHL() { diff --git a/src/main/java/rtg/config/ConfigManager.java b/src/main/java/rtg/config/ConfigManager.java index e2749e31d..89056b3f2 100755 --- a/src/main/java/rtg/config/ConfigManager.java +++ b/src/main/java/rtg/config/ConfigManager.java @@ -1,7 +1,5 @@ package rtg.config; -import java.io.File; - import rtg.config.abyssalcraft.ConfigAC; import rtg.config.arsmagica.ConfigAM; import rtg.config.atg.ConfigATG; @@ -10,6 +8,7 @@ import rtg.config.chromaticraft.ConfigCC; import rtg.config.enhancedbiomes.ConfigEB; import rtg.config.extrabiomes.ConfigEBXL; +import rtg.config.flowercraft.ConfigFC; import rtg.config.forgottennature.ConfigFN; import rtg.config.growthcraft.ConfigGC; import rtg.config.highlands.ConfigHL; @@ -22,6 +21,8 @@ import rtg.config.vampirism.ConfigVAMP; import rtg.config.vanilla.ConfigVanilla; +import java.io.File; + public class ConfigManager { @@ -44,6 +45,7 @@ public class ConfigManager public static File fnConfigFile; public static File icConfigFile; public static File idtConfigFile; + public static File fcConfigFile; private ConfigRTG configRTG = new ConfigRTG(); public ConfigRTG rtg() { @@ -72,6 +74,7 @@ public static void init(String configpath) fnConfigFile = new File(configpath + "biomes/forgottennature.cfg"); icConfigFile = new File(configpath + "biomes/icecreammod.cfg"); idtConfigFile = new File(configpath + "biomes/industrialtechnologies.cfg"); + fcConfigFile = new File(configpath + "biomes/flowercraft.cfg"); ConfigRTG.init(rtgConfigFile); @@ -94,5 +97,6 @@ public static void init(String configpath) ConfigFN.init(fnConfigFile); ConfigIC.init(icConfigFile); ConfigIDT.init(idtConfigFile); + ConfigFC.init(fcConfigFile); } } diff --git a/src/main/java/rtg/config/flowercraft/ConfigFC.java b/src/main/java/rtg/config/flowercraft/ConfigFC.java new file mode 100644 index 000000000..288abfc97 --- /dev/null +++ b/src/main/java/rtg/config/flowercraft/ConfigFC.java @@ -0,0 +1,37 @@ +package rtg.config.flowercraft; + +import net.minecraftforge.common.config.Configuration; +import rtg.api.biome.flowercraft.config.BiomeConfigFC; +import rtg.config.BiomeConfigManager; +import rtg.util.Logger; + +import java.io.File; + +public class ConfigFC +{ + + public static Configuration config; + + public static void init(File configFile) + { + + config = new Configuration(configFile); + + try + { + config.load(); + + BiomeConfigManager.setBiomeConfigsFromUserConfigs(BiomeConfigFC.getBiomeConfigs(), config); + + } catch (Exception e) + { + Logger.error("RTG has had a problem loading FC configuration."); + } finally + { + if (config.hasChanged()) + { + config.save(); + } + } + } +} diff --git a/src/main/java/rtg/world/biome/realistic/flowercraft/RealisticBiomeFCBase.java b/src/main/java/rtg/world/biome/realistic/flowercraft/RealisticBiomeFCBase.java new file mode 100644 index 000000000..f526beb73 --- /dev/null +++ b/src/main/java/rtg/world/biome/realistic/flowercraft/RealisticBiomeFCBase.java @@ -0,0 +1,47 @@ +package rtg.world.biome.realistic.flowercraft; + +import cpw.mods.fml.common.Loader; +import net.minecraft.world.biome.BiomeGenBase; +import rtg.api.biome.BiomeConfig; +import rtg.api.biome.flowercraft.config.BiomeConfigFC; +import rtg.util.Logger; +import rtg.world.biome.realistic.RealisticBiomeBase; +import rtg.world.gen.surface.SurfaceBase; +import rtg.world.gen.terrain.TerrainBase; + +public class RealisticBiomeFCBase extends RealisticBiomeBase { + + public static RealisticBiomeBase fcPhantasia; + + public RealisticBiomeFCBase(BiomeConfig config, BiomeGenBase b, BiomeGenBase riverbiome, TerrainBase t, SurfaceBase s) { + + super(config, b, riverbiome, t, s); + + this.waterSurfaceLakeChance = 0; + this.lavaSurfaceLakeChance = 0; + } + + public static void addBiomes() { + + if (Loader.isModLoaded("flowercraftmod")) { + BiomeGenBase[] b = BiomeGenBase.getBiomeGenArray(); + + for (int i = 0; i < 256; i++) { + if (b[i] != null) { + if (b[i].biomeName == null) { + Logger.warn("Biome ID %d has no name.", b[i].biomeID); + continue; + } + + BiomeGenBase fcBiome = b[i]; + String biomeName = b[i].biomeName; + String biomeClass = b[i].getBiomeClass().getName(); + + if (biomeName == "Phantasia" && biomeClass == "flowercraftmod.world.biome.BiomeGenFCPhantasia") { + fcPhantasia = new RealisticBiomeFCPhantasia(fcBiome, BiomeConfigFC.biomeConfigFCPhantasia); + } + } + } + } + } +} diff --git a/src/main/java/rtg/world/biome/realistic/flowercraft/RealisticBiomeFCPhantasia.java b/src/main/java/rtg/world/biome/realistic/flowercraft/RealisticBiomeFCPhantasia.java new file mode 100644 index 000000000..98cee273e --- /dev/null +++ b/src/main/java/rtg/world/biome/realistic/flowercraft/RealisticBiomeFCPhantasia.java @@ -0,0 +1,23 @@ +package rtg.world.biome.realistic.flowercraft; + +import net.minecraft.world.biome.BiomeGenBase; +import rtg.api.biome.BiomeConfig; +import rtg.world.biome.deco.DecoBaseBiomeDecorations; +import rtg.world.gen.surface.flowercraft.SurfaceFCPhantasia; +import rtg.world.gen.terrain.flowercraft.TerrainFCPhantasia; + +public class RealisticBiomeFCPhantasia extends RealisticBiomeFCBase { + + public RealisticBiomeFCPhantasia(BiomeGenBase fcBiome, BiomeConfig config) { + + super(config, + fcBiome, + BiomeGenBase.river, + new TerrainFCPhantasia(), + new SurfaceFCPhantasia(config, fcBiome.topBlock, fcBiome.fillerBlock) + ); + + DecoBaseBiomeDecorations decoBaseBiomeDecorations = new DecoBaseBiomeDecorations(); + this.addDeco(decoBaseBiomeDecorations); + } +} diff --git a/src/main/java/rtg/world/gen/surface/flowercraft/SurfaceFCBase.java b/src/main/java/rtg/world/gen/surface/flowercraft/SurfaceFCBase.java new file mode 100644 index 000000000..972ec6361 --- /dev/null +++ b/src/main/java/rtg/world/gen/surface/flowercraft/SurfaceFCBase.java @@ -0,0 +1,13 @@ +package rtg.world.gen.surface.flowercraft; + +import net.minecraft.block.Block; +import rtg.api.biome.BiomeConfig; +import rtg.world.gen.surface.SurfaceBase; + + +public class SurfaceFCBase extends SurfaceBase { + + public SurfaceFCBase(BiomeConfig config, Block top, byte topMeta, Block fill, byte fillMeta) { + super(config, top, topMeta, fill, fillMeta); + } +} \ No newline at end of file diff --git a/src/main/java/rtg/world/gen/surface/flowercraft/SurfaceFCPhantasia.java b/src/main/java/rtg/world/gen/surface/flowercraft/SurfaceFCPhantasia.java new file mode 100644 index 000000000..69b9dc660 --- /dev/null +++ b/src/main/java/rtg/world/gen/surface/flowercraft/SurfaceFCPhantasia.java @@ -0,0 +1,59 @@ +package rtg.world.gen.surface.flowercraft; + +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; +import rtg.api.biome.BiomeConfig; +import rtg.util.CellNoise; +import rtg.util.CliffCalculator; +import rtg.util.OpenSimplexNoise; + +import java.util.Random; + +public class SurfaceFCPhantasia extends SurfaceFCBase { + + public SurfaceFCPhantasia(BiomeConfig config, Block top, Block filler) { + super(config, top, (byte) 0, filler, (byte) 0); + } + + @Override + public void paintTerrain(Block[] blocks, byte[] metadata, int i, int j, int x, int y, int depth, World world, Random rand, OpenSimplexNoise simplex, CellNoise cell, float[] noise, float river, BiomeGenBase[] base) { + float c = CliffCalculator.calc(x, y, noise); + boolean cliff = c > 1.4f ? true : false; + + for (int k = 255; k > -1; k--) { + Block b = blocks[(y * 16 + x) * 256 + k]; + if (b == Blocks.air) { + depth = -1; + } else if (b == Blocks.stone) { + depth++; + + if (cliff) { + if (depth > -1 && depth < 2) { + if (rand.nextInt(3) == 0) { + + blocks[(y * 16 + x) * 256 + k] = hcCobble(world, i, j, x, y, k); + metadata[(y * 16 + x) * 256 + k] = hcCobbleMeta(world, i, j, x, y, k); + } else { + + blocks[(y * 16 + x) * 256 + k] = hcStone(world, i, j, x, y, k); + metadata[(y * 16 + x) * 256 + k] = hcStoneMeta(world, i, j, x, y, k); + } + } else if (depth < 10) { + blocks[(y * 16 + x) * 256 + k] = hcStone(world, i, j, x, y, k); + metadata[(y * 16 + x) * 256 + k] = hcStoneMeta(world, i, j, x, y, k); + } + } else { + if (depth == 0 && k > 61) { + blocks[(y * 16 + x) * 256 + k] = topBlock; + metadata[(y * 16 + x) * 256 + k] = topBlockMeta; + } else if (depth < 4) { + blocks[(y * 16 + x) * 256 + k] = fillerBlock; + metadata[(y * 16 + x) * 256 + k] = fillerBlockMeta; + } + } + } + } + } +} diff --git a/src/main/java/rtg/world/gen/terrain/flowercraft/TerrainFCPhantasia.java b/src/main/java/rtg/world/gen/terrain/flowercraft/TerrainFCPhantasia.java new file mode 100644 index 000000000..f81f8cc64 --- /dev/null +++ b/src/main/java/rtg/world/gen/terrain/flowercraft/TerrainFCPhantasia.java @@ -0,0 +1,21 @@ +package rtg.world.gen.terrain.flowercraft; + +import rtg.util.CellNoise; +import rtg.util.OpenSimplexNoise; +import rtg.world.gen.terrain.GroundEffect; +import rtg.world.gen.terrain.TerrainBase; + +public class TerrainFCPhantasia extends TerrainBase { + + public TerrainFCPhantasia() { + + } + + @Override + public float generateNoise(OpenSimplexNoise simplex, CellNoise cell, int x, int y, float border, float river) { + //return terrainPlains(x, y, simplex, river, 160f, 10f, 60f, 200f, 66f); + return riverized(65f + groundEffect.added(simplex, cell, x, y), river); + } + + private GroundEffect groundEffect = new GroundEffect(4f); +} From a922e6de57ca2faf06e36956058f4762ec12803b Mon Sep 17 00:00:00 2001 From: WhichOnesPink Date: Sat, 23 Jul 2016 17:06:22 +0100 Subject: [PATCH 16/22] Updated example configs. --- etc/config/RTG/biomes/flowercraft.cfg | 61 +++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 etc/config/RTG/biomes/flowercraft.cfg diff --git a/etc/config/RTG/biomes/flowercraft.cfg b/etc/config/RTG/biomes/flowercraft.cfg new file mode 100644 index 000000000..baa39ba93 --- /dev/null +++ b/etc/config/RTG/biomes/flowercraft.cfg @@ -0,0 +1,61 @@ +# Configuration file + +biome { + + flowercraft { + + phantasia { + # [default: true] + B:"Allow Villages"=true + + # [default: false] + B:"Allow Volcanoes"=false + + # This setting controls the size of caves. + # HIGHER values = BIGGER caves & MORE lag. (14 = vanilla cave density) + # Set to -1 to use global setting. Set to 0 to disable caves for this biome. + # [range: -1 ~ 40, default: -1] + I:"Cave Density"=-1 + + # This setting controls the number of caves that generate. + # LOWER values = MORE caves & MORE lag. (6 = vanilla cave frequency) + # Set to -1 to use global setting. Set to 0 to disable caves for this biome. + # [range: -1 ~ 40, default: -1] + I:"Cave Frequency"=-1 + + # [default: ] + S:"RTG Surface: Filler Block"= + + # [default: ] + S:"RTG Surface: Filler Block Meta"= + + # [default: ] + S:"RTG Surface: Top Block"= + + # [default: ] + S:"RTG Surface: Top Block Meta"= + + # This setting controls the number of ravines that generate. + # LOWER values = MORE ravines & MORE lag. (50 = vanilla ravine frequency) + # Set to -1 to use global setting. Set to 0 to disable ravines for this biome. + # [range: -1 ~ 100, default: -1] + I:"Ravine Frequency"=-1 + + # [default: true] + B:"Use RTG Decorations"=true + + # [default: true] + B:"Use RTG Surfaces"=true + + # 1/x chance that a volcano will generate if this biome has volcanoes enabled. + # 1 = Always generate if possible; 2 = 50% chance; 4 = 25% chance + # Set to -1 to use global setting. Set to 0 to disable volcanoes for this biome. + # [range: -1 ~ 2147483647, default: -1] + I:"Volcano Chance"=-1 + } + + } + +} + + From 1026ee46ae52f687061724e40c24def1ad9df1c0 Mon Sep 17 00:00:00 2001 From: WhichOnesPink Date: Sat, 23 Jul 2016 17:20:58 +0100 Subject: [PATCH 17/22] RTG saplings only work in the Overworld. --- src/main/java/rtg/event/EventManagerRTG.java | 38 +++++++++++++------- 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/src/main/java/rtg/event/EventManagerRTG.java b/src/main/java/rtg/event/EventManagerRTG.java index 383e505c5..f8f63e416 100755 --- a/src/main/java/rtg/event/EventManagerRTG.java +++ b/src/main/java/rtg/event/EventManagerRTG.java @@ -1,9 +1,8 @@ package rtg.event; -import java.util.ArrayList; -import java.util.Random; -import java.util.WeakHashMap; - +import cpw.mods.fml.common.eventhandler.Event.Result; +import cpw.mods.fml.common.eventhandler.EventPriority; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.world.World; @@ -29,9 +28,10 @@ import rtg.world.gen.genlayer.RiverRemover; import rtg.world.gen.structure.MapGenScatteredFeatureRTG; import rtg.world.gen.structure.MapGenVillageRTG; -import cpw.mods.fml.common.eventhandler.Event.Result; -import cpw.mods.fml.common.eventhandler.EventPriority; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; + +import java.util.ArrayList; +import java.util.Random; +import java.util.WeakHashMap; public class EventManagerRTG { @@ -184,11 +184,19 @@ public class SaplingGrowTreeRTG @SubscribeEvent public void saplingGrowTreeRTG(SaplingGrowTreeEvent event) { - + // Are RTG saplings enabled? - if (!ConfigRTG.enableRTGSaplings) { return; } + if (!ConfigRTG.enableRTGSaplings) { + return; + } + + // Are we in an RTG world? Do we have RTG's chunk manager? + if (!(event.world.getWorldInfo().getTerrainType() instanceof WorldTypeRTG) || !(event.world.getWorldChunkManager() instanceof WorldChunkManagerRTG)) { + return; + } Random rand = event.rand; + // Should we generate a vanilla tree instead? if (rand.nextInt(ConfigRTG.rtgTreeChance) != 0) { @@ -215,6 +223,7 @@ public void saplingGrowTreeRTG(SaplingGrowTreeEvent event) { Logger.debug("Ground Sapling Meta = %d", saplingMeta); if (biomeTrees.size() > 0) { + // First, let's get all of the trees in this biome that match the sapling on the ground. ArrayList validTrees = new ArrayList<>(); @@ -230,8 +239,10 @@ public void saplingGrowTreeRTG(SaplingGrowTreeEvent event) { Logger.debug("Valid tree found!"); } } + // If there are valid trees, then proceed; otherwise, let's get out here. if (validTrees.size() > 0) { + // Get a random tree from the list of valid trees. TreeRTG tree = validTrees.get(rand.nextInt(validTrees.size())); @@ -253,7 +264,7 @@ public void saplingGrowTreeRTG(SaplingGrowTreeEvent event) { * Set the generateFlag to what it needs to be for growing trees from saplings, * generate the tree, and then set it back to what it was before. * - * TODO: Does this affect the generation of normal RTG trees? + * TODO: Does this affect the generation of normal RTG trees? - Pink */ int oldFlag = tree.generateFlag; tree.generateFlag = 3; @@ -271,8 +282,11 @@ public void saplingGrowTreeRTG(SaplingGrowTreeEvent event) { } } } - else Logger.debug("There are no RTG trees associated with the sapling on the ground." + - " Generating a vanilla tree instead."); + else { + + Logger.debug("There are no RTG trees associated with the sapling on the ground." + + " Generating a vanilla tree instead."); + } } } } From 9e01287e20c6d55223e6f5d0d2dbe0d1296171d0 Mon Sep 17 00:00:00 2001 From: WhichOnesPink Date: Sun, 24 Jul 2016 16:59:06 +0100 Subject: [PATCH 18/22] Added world type notification screen. --- src/main/java/rtg/RTG.java | 20 ++-- .../rtg/client/gui/WorldTypeMessageGUI.java | 103 ++++++++++++++++++ .../event/WorldTypeMessageEventHandler.java | 54 +++++++++ src/main/resources/assets/rtg/lang/da_DK.lang | 7 ++ src/main/resources/assets/rtg/lang/de_DE.lang | 9 +- src/main/resources/assets/rtg/lang/en_GB.lang | 9 +- src/main/resources/assets/rtg/lang/en_US.lang | 9 +- src/main/resources/assets/rtg/lang/es_ES.lang | 9 +- src/main/resources/assets/rtg/lang/fr_FR.lang | 9 +- src/main/resources/assets/rtg/lang/it_IT.lang | 9 +- src/main/resources/assets/rtg/lang/ko_KR.lang | 9 +- src/main/resources/assets/rtg/lang/pt_PT.lang | 9 +- src/main/resources/assets/rtg/lang/ru_RU.lang | 9 +- src/main/resources/assets/rtg/lang/zh_CN.lang | 9 +- .../rtg/textures/gui/rtg-logo-worldtype.png | Bin 0 -> 2582 bytes 15 files changed, 257 insertions(+), 17 deletions(-) create mode 100644 src/main/java/rtg/client/gui/WorldTypeMessageGUI.java create mode 100644 src/main/java/rtg/event/WorldTypeMessageEventHandler.java create mode 100644 src/main/resources/assets/rtg/textures/gui/rtg-logo-worldtype.png diff --git a/src/main/java/rtg/RTG.java b/src/main/java/rtg/RTG.java index daa05b308..ac0800e8d 100755 --- a/src/main/java/rtg/RTG.java +++ b/src/main/java/rtg/RTG.java @@ -1,17 +1,16 @@ package rtg; -import cpw.mods.fml.common.Mod; -import cpw.mods.fml.common.Mod.EventHandler; -import cpw.mods.fml.common.Mod.Instance; -import cpw.mods.fml.common.event.FMLPostInitializationEvent; -import cpw.mods.fml.common.event.FMLPreInitializationEvent; -import cpw.mods.fml.common.event.FMLServerStoppedEvent; +import java.util.ArrayList; + import net.minecraft.world.gen.structure.MapGenStructureIO; + import net.minecraftforge.common.MinecraftForge; + import rtg.api.event.BiomeConfigEvent; import rtg.config.BiomeConfigManager; import rtg.config.ConfigManager; import rtg.event.EventManagerRTG; +import rtg.event.WorldTypeMessageEventHandler; import rtg.reference.ModInfo; import rtg.util.Logger; import rtg.util.RealisticBiomePresenceTester; @@ -39,7 +38,12 @@ import rtg.world.gen.structure.MapGenScatteredFeatureRTG; import rtg.world.gen.structure.MapGenVillageRTG; -import java.util.ArrayList; +import cpw.mods.fml.common.Mod; +import cpw.mods.fml.common.Mod.EventHandler; +import cpw.mods.fml.common.Mod.Instance; +import cpw.mods.fml.common.event.FMLPostInitializationEvent; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import cpw.mods.fml.common.event.FMLServerStoppedEvent; //@Mod(modid = "RTG", name = "Realistic Terrain Generaton", version = "0.8.0d", dependencies = "required-after:Forge@[10.13.4.1448,)", acceptableRemoteVersions = "*") @@ -69,6 +73,8 @@ public void preInit(FMLPreInitializationEvent event) Logger.info("[FMLPreInitializationEvent] Creating RTG's EventManager"); eventMgr = new EventManagerRTG(); + MinecraftForge.EVENT_BUS.register(WorldTypeMessageEventHandler.instance); + MinecraftForge.EVENT_BUS.post(new BiomeConfigEvent.Pre()); // This MUST get called before the config is initialised. diff --git a/src/main/java/rtg/client/gui/WorldTypeMessageGUI.java b/src/main/java/rtg/client/gui/WorldTypeMessageGUI.java new file mode 100644 index 000000000..431e1eccf --- /dev/null +++ b/src/main/java/rtg/client/gui/WorldTypeMessageGUI.java @@ -0,0 +1,103 @@ +package rtg.client.gui; + +import java.io.File; +import java.io.IOException; + +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.resources.I18n; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; +import static net.minecraft.util.EnumChatFormatting.DARK_RED; +import static net.minecraft.util.EnumChatFormatting.WHITE; + +import org.apache.commons.io.FileUtils; +import org.lwjgl.input.Keyboard; +import org.lwjgl.opengl.GL11; + +/** + * Displays a notification screen when creating a new world. + * + * @author @Adubbz (https://github.com/Adubbz) + * + * Source: https://github.com/Glitchfiend/BiomesOPlenty/blob/BOP-1.7.10-2.1.x/src/main/java/biomesoplenty/client/gui/WorldTypeMessageGUI.java + * Modified by: WhichOnesPink (https://github.com/whichonespink44) + */ +public class WorldTypeMessageGUI extends GuiScreen +{ + private GuiScreen parentGuiScreen; + + private File nameHashFile; + private String nameHash; + + private static final ResourceLocation rtgLogoTexture = new ResourceLocation("rtg:textures/gui/rtg-logo-worldtype.png"); + + public WorldTypeMessageGUI(GuiScreen parentGuiScreen, File nameHashFile, String nameHash) + { + this.parentGuiScreen = parentGuiScreen; + + this.nameHashFile = nameHashFile; + this.nameHash = nameHash; + } + + @Override + public void initGui() + { + Keyboard.enableRepeatEvents(true); + this.buttonList.clear(); + this.buttonList.add(new GuiButton(0, this.width / 2 - 175, this.height - 24, 350, 20, I18n.format("OK"))); + } + + @Override + public void onGuiClosed() + { + Keyboard.enableRepeatEvents(false); + } + + @Override + protected void actionPerformed(GuiButton button) + { + if (button.enabled) + { + if (button.id == 0) + { + try + { + nameHashFile.createNewFile(); + FileUtils.write(nameHashFile, nameHash + "StartupWarning".hashCode()); + } + catch (IOException e) + { + e.printStackTrace(); + } + + this.mc.displayGuiScreen(this.parentGuiScreen); + } + } + } + + @Override + public void drawScreen(int x, int y, float renderPartialTicks) + { + this.drawDefaultBackground(); + + this.drawCenteredString(this.fontRendererObj, "" + WHITE + StatCollector.translateToLocal("warning.rtgStartup1"), this.width / 2, 82, 0xFFFFFF); + this.drawCenteredString(this.fontRendererObj, "" + WHITE + StatCollector.translateToLocal("warning.rtgStartup2"), this.width / 2, 94, 0xFFFFFF); + this.drawCenteredString(this.fontRendererObj, "" + WHITE + StatCollector.translateToLocal("warning.rtgStartup3"), this.width / 2, 106, 0xFFFFFF); + + this.drawCenteredString(this.fontRendererObj, "" + WHITE + StatCollector.translateToLocal("warning.rtgStartup4"), this.width / 2, 132, 0xFFFFFF); + this.drawCenteredString(this.fontRendererObj, "" + WHITE + StatCollector.translateToLocal("warning.rtgStartup5"), this.width / 2, 144, 0xFFFFFF); + + this.drawCenteredString(this.fontRendererObj, "" + DARK_RED + StatCollector.translateToLocal("warning.rtgStartup6"), this.width / 2, 168, 0xFFFFFF); + + GL11.glEnable(GL11.GL_BLEND); + this.mc.getTextureManager().bindTexture(rtgLogoTexture); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + + this.drawTexturedModalRect(this.width / 2 - 168 / 2, 0, 0, 0, 168, 80); + + GL11.glDisable(GL11.GL_BLEND); + + super.drawScreen(x, y, renderPartialTicks); + } +} diff --git a/src/main/java/rtg/event/WorldTypeMessageEventHandler.java b/src/main/java/rtg/event/WorldTypeMessageEventHandler.java new file mode 100644 index 000000000..dbd77e1da --- /dev/null +++ b/src/main/java/rtg/event/WorldTypeMessageEventHandler.java @@ -0,0 +1,54 @@ +package rtg.event; + +import java.io.File; +import java.io.IOException; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiCreateWorld; + +import net.minecraftforge.client.event.GuiOpenEvent; +import net.minecraftforge.common.MinecraftForge; + +import rtg.client.gui.WorldTypeMessageGUI; + +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import org.apache.commons.io.FileUtils; + +/** + * Handles the display of the notification screen when creating a new world. + * + * @author @Adubbz (https://github.com/Adubbz) + * + * Source: https://github.com/Glitchfiend/BiomesOPlenty/blob/BOP-1.7.10-2.1.x/src/main/java/biomesoplenty/common/eventhandler/client/gui/WorldTypeMessageEventHandler.java + * Modified by: WhichOnesPink (https://github.com/whichonespink44) + */ +public class WorldTypeMessageEventHandler +{ + public static WorldTypeMessageEventHandler instance = new WorldTypeMessageEventHandler(); + + @SubscribeEvent + @SideOnly(Side.CLIENT) + public void openCreateWorld(GuiOpenEvent event) + { + if (event.gui instanceof GuiCreateWorld) + { + File nameHashFile = new File(Minecraft.getMinecraft().mcDataDir.getPath() + File.separator + "RTGChecks".hashCode()); + String nameHash = "" + Minecraft.getMinecraft().getSession().func_148256_e().hashCode(); + + try + { + if (!nameHashFile.exists() || !FileUtils.readFileToString(nameHashFile).contains(nameHash + "StartupWarning".hashCode())) + { + event.gui = new WorldTypeMessageGUI(event.gui, nameHashFile, nameHash); + } + } catch (IOException e) + { + e.printStackTrace(); + } + + MinecraftForge.EVENT_BUS.unregister(instance); + } + } +} diff --git a/src/main/resources/assets/rtg/lang/da_DK.lang b/src/main/resources/assets/rtg/lang/da_DK.lang index 14ee5668b..e4163ca83 100644 --- a/src/main/resources/assets/rtg/lang/da_DK.lang +++ b/src/main/resources/assets/rtg/lang/da_DK.lang @@ -1 +1,8 @@ generator.RTG=Realistisk + +warning.rtgStartup1=Realistic Terrain Generation uses a custom world type. +warning.rtgStartup2=If you want realistic terrain, keep clicking the 'World Type' button +warning.rtgStartup3=under 'More World Options' until it displays 'Realistic'. +warning.rtgStartup4=The world type can be used on servers by changing the 'level-type' in +warning.rtgStartup5=server.properties to 'RTG' (without quotes). +warning.rtgStartup6=This message will only display once. diff --git a/src/main/resources/assets/rtg/lang/de_DE.lang b/src/main/resources/assets/rtg/lang/de_DE.lang index 7576164d8..bbcc73651 100644 --- a/src/main/resources/assets/rtg/lang/de_DE.lang +++ b/src/main/resources/assets/rtg/lang/de_DE.lang @@ -1 +1,8 @@ -generator.RTG=Realistisch \ No newline at end of file +generator.RTG=Realistisch + +warning.rtgStartup1=Realistic Terrain Generation uses a custom world type. +warning.rtgStartup2=If you want realistic terrain, keep clicking the 'World Type' button +warning.rtgStartup3=under 'More World Options' until it displays 'Realistic'. +warning.rtgStartup4=The world type can be used on servers by changing the 'level-type' in +warning.rtgStartup5=server.properties to 'RTG' (without quotes). +warning.rtgStartup6=This message will only display once. diff --git a/src/main/resources/assets/rtg/lang/en_GB.lang b/src/main/resources/assets/rtg/lang/en_GB.lang index 9c8332645..362d54232 100644 --- a/src/main/resources/assets/rtg/lang/en_GB.lang +++ b/src/main/resources/assets/rtg/lang/en_GB.lang @@ -1 +1,8 @@ -generator.RTG=Realistic \ No newline at end of file +generator.RTG=Realistic + +warning.rtgStartup1=Realistic Terrain Generation uses a custom world type. +warning.rtgStartup2=If you want realistic terrain, keep clicking the 'World Type' button +warning.rtgStartup3=under 'More World Options' until it displays 'Realistic'. +warning.rtgStartup4=The world type can be used on servers by changing the 'level-type' in +warning.rtgStartup5=server.properties to 'RTG' (without quotes). +warning.rtgStartup6=This message will only display once. diff --git a/src/main/resources/assets/rtg/lang/en_US.lang b/src/main/resources/assets/rtg/lang/en_US.lang index 9c8332645..362d54232 100644 --- a/src/main/resources/assets/rtg/lang/en_US.lang +++ b/src/main/resources/assets/rtg/lang/en_US.lang @@ -1 +1,8 @@ -generator.RTG=Realistic \ No newline at end of file +generator.RTG=Realistic + +warning.rtgStartup1=Realistic Terrain Generation uses a custom world type. +warning.rtgStartup2=If you want realistic terrain, keep clicking the 'World Type' button +warning.rtgStartup3=under 'More World Options' until it displays 'Realistic'. +warning.rtgStartup4=The world type can be used on servers by changing the 'level-type' in +warning.rtgStartup5=server.properties to 'RTG' (without quotes). +warning.rtgStartup6=This message will only display once. diff --git a/src/main/resources/assets/rtg/lang/es_ES.lang b/src/main/resources/assets/rtg/lang/es_ES.lang index 65b462d03..6309b67bf 100644 --- a/src/main/resources/assets/rtg/lang/es_ES.lang +++ b/src/main/resources/assets/rtg/lang/es_ES.lang @@ -1 +1,8 @@ -generator.RTG=Realista \ No newline at end of file +generator.RTG=Realista + +warning.rtgStartup1=Realistic Terrain Generation uses a custom world type. +warning.rtgStartup2=If you want realistic terrain, keep clicking the 'World Type' button +warning.rtgStartup3=under 'More World Options' until it displays 'Realistic'. +warning.rtgStartup4=The world type can be used on servers by changing the 'level-type' in +warning.rtgStartup5=server.properties to 'RTG' (without quotes). +warning.rtgStartup6=This message will only display once. diff --git a/src/main/resources/assets/rtg/lang/fr_FR.lang b/src/main/resources/assets/rtg/lang/fr_FR.lang index 16f4cb3ab..74ca53ae6 100644 --- a/src/main/resources/assets/rtg/lang/fr_FR.lang +++ b/src/main/resources/assets/rtg/lang/fr_FR.lang @@ -1 +1,8 @@ -generator.RTG=Réaliste \ No newline at end of file +generator.RTG=Réaliste + +warning.rtgStartup1=Realistic Terrain Generation uses a custom world type. +warning.rtgStartup2=If you want realistic terrain, keep clicking the 'World Type' button +warning.rtgStartup3=under 'More World Options' until it displays 'Realistic'. +warning.rtgStartup4=The world type can be used on servers by changing the 'level-type' in +warning.rtgStartup5=server.properties to 'RTG' (without quotes). +warning.rtgStartup6=This message will only display once. diff --git a/src/main/resources/assets/rtg/lang/it_IT.lang b/src/main/resources/assets/rtg/lang/it_IT.lang index 40ce77a14..266248a7a 100644 --- a/src/main/resources/assets/rtg/lang/it_IT.lang +++ b/src/main/resources/assets/rtg/lang/it_IT.lang @@ -1 +1,8 @@ -generator.RTG=Realistico \ No newline at end of file +generator.RTG=Realistico + +warning.rtgStartup1=Realistic Terrain Generation uses a custom world type. +warning.rtgStartup2=If you want realistic terrain, keep clicking the 'World Type' button +warning.rtgStartup3=under 'More World Options' until it displays 'Realistic'. +warning.rtgStartup4=The world type can be used on servers by changing the 'level-type' in +warning.rtgStartup5=server.properties to 'RTG' (without quotes). +warning.rtgStartup6=This message will only display once. diff --git a/src/main/resources/assets/rtg/lang/ko_KR.lang b/src/main/resources/assets/rtg/lang/ko_KR.lang index 4d53e6523..49337d45a 100644 --- a/src/main/resources/assets/rtg/lang/ko_KR.lang +++ b/src/main/resources/assets/rtg/lang/ko_KR.lang @@ -1 +1,8 @@ -generator.RTG=현실적인 바이옴 \ No newline at end of file +generator.RTG=현실적인 바이옴 + +warning.rtgStartup1=Realistic Terrain Generation uses a custom world type. +warning.rtgStartup2=If you want realistic terrain, keep clicking the 'World Type' button +warning.rtgStartup3=under 'More World Options' until it displays 'Realistic'. +warning.rtgStartup4=The world type can be used on servers by changing the 'level-type' in +warning.rtgStartup5=server.properties to 'RTG' (without quotes). +warning.rtgStartup6=This message will only display once. diff --git a/src/main/resources/assets/rtg/lang/pt_PT.lang b/src/main/resources/assets/rtg/lang/pt_PT.lang index 65b462d03..6309b67bf 100644 --- a/src/main/resources/assets/rtg/lang/pt_PT.lang +++ b/src/main/resources/assets/rtg/lang/pt_PT.lang @@ -1 +1,8 @@ -generator.RTG=Realista \ No newline at end of file +generator.RTG=Realista + +warning.rtgStartup1=Realistic Terrain Generation uses a custom world type. +warning.rtgStartup2=If you want realistic terrain, keep clicking the 'World Type' button +warning.rtgStartup3=under 'More World Options' until it displays 'Realistic'. +warning.rtgStartup4=The world type can be used on servers by changing the 'level-type' in +warning.rtgStartup5=server.properties to 'RTG' (without quotes). +warning.rtgStartup6=This message will only display once. diff --git a/src/main/resources/assets/rtg/lang/ru_RU.lang b/src/main/resources/assets/rtg/lang/ru_RU.lang index 4e46d86ae..412e54b00 100644 --- a/src/main/resources/assets/rtg/lang/ru_RU.lang +++ b/src/main/resources/assets/rtg/lang/ru_RU.lang @@ -1 +1,8 @@ -generator.RTG=Реалистичный \ No newline at end of file +generator.RTG=Реалистичный + +warning.rtgStartup1=Realistic Terrain Generation uses a custom world type. +warning.rtgStartup2=If you want realistic terrain, keep clicking the 'World Type' button +warning.rtgStartup3=under 'More World Options' until it displays 'Realistic'. +warning.rtgStartup4=The world type can be used on servers by changing the 'level-type' in +warning.rtgStartup5=server.properties to 'RTG' (without quotes). +warning.rtgStartup6=This message will only display once. diff --git a/src/main/resources/assets/rtg/lang/zh_CN.lang b/src/main/resources/assets/rtg/lang/zh_CN.lang index 3522e6a6b..3ebca5adf 100644 --- a/src/main/resources/assets/rtg/lang/zh_CN.lang +++ b/src/main/resources/assets/rtg/lang/zh_CN.lang @@ -1 +1,8 @@ -generator.RTG=真实世界生成 \ No newline at end of file +generator.RTG=真实世界生成 + +warning.rtgStartup1=Realistic Terrain Generation uses a custom world type. +warning.rtgStartup2=If you want realistic terrain, keep clicking the 'World Type' button +warning.rtgStartup3=under 'More World Options' until it displays 'Realistic'. +warning.rtgStartup4=The world type can be used on servers by changing the 'level-type' in +warning.rtgStartup5=server.properties to 'RTG' (without quotes). +warning.rtgStartup6=This message will only display once. diff --git a/src/main/resources/assets/rtg/textures/gui/rtg-logo-worldtype.png b/src/main/resources/assets/rtg/textures/gui/rtg-logo-worldtype.png new file mode 100644 index 0000000000000000000000000000000000000000..6bdb51932c81b9fdf383ebd3d627fd6c201edaca GIT binary patch literal 2582 zcmdT``#;l*8=utXlAMlH5)rF>u}E{xW$6ru((Rnw@623_31=>mb6%87Ysk!HI!;|2nC;54@)c5UyFy^wCd{5rM#7F%-U$|1;?fbaZoCabYaVL)j<c-}U-=FzTJ-!6;yPBH~9(vHRWCN0a(DvO;un4I(ufD^4=ROtde9GZ&n3|=A zWJ`XTIy1}r#3K=BAG)~K^J{o@58G~B2@$<+@uOxY?%wwC@5*bgpvCcD0lLtjj1a@{ z{YVtTMl1&=@T=p$o}h(sQL4W8Dg15^5^R}NR6CZYcXMx%H}eL64X^FK0xQq5#Kdt? z;F!batC}XFTfw^625JkUBzXO48$+e4f%3H5vkkYERdnx0!%HY6o$1nlw_(6A%wmP& ztkdO8%i&IgE$S!-^jmkLs`MT0#N~RVRntxfjC=HS8$awdR^Hd#{5#BJN~SR zrw0kak-oLSTp{v!avq?UmSaSUcCnvCk#uF@abWF2Jj&^za1;^)+r!r~sXQ622$xtkR?OhX~*dj2jMzUjaC1^bl zm}_h=_4Bm*{0;uQS+QzHJwRZU!IMbx{Yb;A0b(*%p(FFpT{w9k=H$6zba99#CK>R0 zENi42M#Kl=J}OFHSkdS=Mpx8=w?2-a+s|@)A;WjGk_q}UX_g5jO^zM7I3GS^F76t? z(HOEflgptVx=3oR#qFUC>-r=*&ntEJP^x6za8urj4s_0fvp9U8yY%1>s{8tJPF~a< zw_4qyUML&6QLH@XHgFE0|{ZeGB>?!^)eTd722^|(eqw8pO+oS zuQdB*lFr&J26mB&ku?`yE$`(SW5W3%cu_@+cvu{Lbf|L?;+)+W7g$)UeZXR<42roc2PRLKP*Cf-;rdG4=#PnD#eu+e`6HAz@| zWGX7FJtUjRTZ>jL*IE#S7-_afc&CObX3c#2Z)jJvSYUK+n6_n3yE1nw z^pGq*fWFE?bqYxmRlAz!ilLxf>VJH2g0}z~I#;x1BQ6{-IqUqhMT&CqyxnEf3;x`| zCn+1=aYj*qOs8qh-mv{lMNGw3^Y|=txpY0(6*F+8^z^LZG-fA?*I^T~ICL<7HE`9g z^`3ZR>OcttMu4s_AqAZA-riwN9XsU`+0Q3H-tU0AhAN84uwthWO^i(6AmnK;jzBeS!^0yOOpAm25*m2{d>)o zG*2JB-P3B5u{U!%ElSZVq;(uLBLz$I2onqEIX$E0Gq}uW{=PCjXdv|=fJ=ELONW86@v5LEOuu(y4QEoKLxa` z+x6&in8gxL@+LE#W1uTb)ywA8_w^<3L2 zcd^>KG;z12TTQztyIBMWRQ~cy3-R!^CKDO;Geh*O4*{!U#kb5fp6aInG;Oca`K*ys zK8D%h`-LuLO~;}My`FIiQ7K{atP$FDgD}S_Kc^iX*BkGggGz}Vj0}C4g{_jveY1l&@y;H_e$St}e@nD32h?(D#Is=$^(et#f+Np1Bbx1@yA~n)`)>WAMO4P?MxhF8Ey(%{CX51A@4u2XF03M6>i=MOgw4`YLlTkZPR^gysCHN!JrcP6-U=!(2FZTU<( z8S8A9wNGTm`5B`L{(9yruE&WsbXO>kqOJy(588Vdom&n>O~sf4*sDla-`O=*fW4K9t{5c9nYl<{yNkE>lIA^-d1AJ*p<@Yn%m;H zE-$3hh|p9vC1a(zVLjWfsOQAVzGF*qd~|z=eEJlAIuha2)$|vu<%!BI)yRd7l)xi> z!;vi=WDA8H&o=RU@%+oH>$8tTcO=3m4U(t1!#Mtru1>G})+}|VSXGOF$5I=BGvT_g z+!9x`WqkNVu?cIcoO>1=X@r~BiEBZ3Do_$g6*%4IiEB$XXtp8 zCVErWxkZICaJKs_N82vx^!&$w|PT{o%+VScYji{W$m$=#xLex&pc-r*Sc9F99O6 c&vr}++Awwsm{5=X@=p>k_w&fMGvWFF10{CV{Qv*} literal 0 HcmV?d00001 From 5fcd04ca0e4e1d2f6aa8864a792267b1303ed1a1 Mon Sep 17 00:00:00 2001 From: WhichOnesPink Date: Sun, 24 Jul 2016 18:02:28 +0100 Subject: [PATCH 19/22] Centered the logo in the world type screen. --- .../rtg/textures/gui/rtg-logo-worldtype.png | Bin 2582 -> 2564 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/src/main/resources/assets/rtg/textures/gui/rtg-logo-worldtype.png b/src/main/resources/assets/rtg/textures/gui/rtg-logo-worldtype.png index 6bdb51932c81b9fdf383ebd3d627fd6c201edaca..59c5e09263eee104c67a706344f3519009d82919 100644 GIT binary patch delta 2309 zcmV+g3HtVy6oeFzEe8-Y8=o~D?vXSof0Ic>K~#9!?cI5dB}E+v@L5(axeo;cD2FI= zqoSf1JhGrD5raomM57o%qo80+l!zMf)({npiW(F}MM6XqJP_PJ_(Q^_fC_O#KqMPj zF1cA|%HJH- ze}LgiDSJdd8~JnO`CXR>SPP=Eza?^AWU{PsPvnTM%Lc4LQOOU8JX+eVjGWwc8G$(z zm3q6#+aq6&EGxrJMb7KG%)l%}CEhvm(a7bI$7{tNRW5sc*ZTmBDJt$kk)@F*#;o-H z9*ivMdVhcsL}gtR`9S2MSycMAK7k)afA;Kp|6tyUim}Z+D8uHFVx{@IUH=|n zt%{R=r^q)W_x4qo{Q2g{agie;yU*b^w<=BV{n?Q#dn)^=6*iaqduiJ9gIpSUe_!PK z5!ai`+z{EP>)#2iadDzQBl3+hdfWQ`$hRU#MmC+{Hus7AxK`Ym-rchk@Wi^lPYqem zWp$awk&j0n8FBp&MBdx=?+0crD{5qm$c8t(#?*9e{O+ z$R&|e>iSoXu&%6h*|UE_X1l%z4=`!;+{bW7S4;pcMImbSm7o+s1f45zXZjT($x6bYB zKHS~1{EEoYGdM0^Dx;4f$YrvLa#rbU#>AhWQ`fb8z`F8+cz$HduFnP5GjY-#T$*|B zQ$tSdVe+Ita)#U9E%K8x+7rRF8zZ~+tYhEE_e=Zhz`Qe`7ujhR$0y%>WanT`8p<&a zIk+hw@3RB&&U%5Ee=JXJ?pzx=rf*&OrXdGNT~gX7AN?o)z3X#=^+0Jx>wT>Z?&QnI z-rtty(RR>9U|DZvoJCo(GwtFs{82m0kj;l}OViFiJo3ku&rEmHWyj#04LBN7_Ix9- zb!pxTWOHXpt>hn!oHXQfIcO^9C1l6peLcr`s_xgUk1MpQe|NN-2UP4Q>RoQ1y6k5L zESGKY=gnc6a=d<9+kLuHWRoGADuzx$hg-3)-bU`*m^G z?qH zkn9D2WWaVVi#)e3drIG9a+dkTb?t6H;xW0g?q@d7-q>}SSck<4v}FtzefArnTo_~8!=^2{45R|50W3$LE zrTG@(>En{anqSa$`B=x4roDV>J%Re=d+BdSwy(?PMdFub_}KZWy1rReywXh7y{rs= z9rnG*c0J4Iz@+QyzyG%^fG^&Neb}-zorR~BW}s0%%{)}^_>(QiCi_O#c!wqnM4T)y zFYT}PfAY`2o4%uzX0+S%yYBww`iH`vKg%-ZwB0jH`&);}TCV+DK6h$aH3#9~u8-|3 z_CE(GWgo`UGI*HrF!$GEu~FCi!aP-)S7dnyZF@ELx5(jjxo4JU`s<4F6nF-ucH>pA;6?-|6d1^Bn}MyAV89kN1M= z5M>0Vc|>m;5R;GbIn!*HHMHG4Npmd!e;Xp7EX}mo8|rr39`W-P-$nI8HP*NPl=XO6 zY(36L)r)k_amZ=JIZ$X>S=F4F&IMhUm(`n-FU2g))YF{L{))bJJ`(wPz*hMVyPpx!z2ZkS`s5A0c2R<`Alb0TNQNw9p3b>@ka6+D{&`BorD(&a0*eBHEF z&o+jYJGcLM)PPcfj^WK_!A}bjDs!^{n_$ep%)X6RRrxH8XvjF3tbKDl7j36HSG_yJotAXYT9y`JvcWnaQ@3K?%H* fPzenfn6Lg1k@vc*hj?yb00000NkvXXu0mjfNkz|S delta 2331 zcmV+$3FP*K6qXc_Ee8xF2b+tZBat*Hf2B!8K~#9!?c8~cBvl;;@L3R8fp7@RjV#EG zf(M9ziX0M&1_>c5hY~^%32KZ7ga|=2ks}&8jQ9tF8a3d72Jb`&;t2vO1Qh`>f~X+7 zEC?e-%|-l;u4pX8g_ovE&VRbB7Zt5>gjYzzPZ0000000000e*gdg z00000fU1#-D)9>uQC9$zc&f2ceYxjeFc*V_gwov0WatORA48#y-elNp}zC$l(m zMP%Eqw--7Um0-Qd(UC9IigD;HzW3U-i~rWh$0I*1&4~U?D*pJ8ug_)v6*({WLD!!H z%&Iu(w~kyK`R9ZRlmGsGX}aHsN9K?4JvXXn_w0uMyjH+rD{QZ9cbDe&f8HQBMBZ7K z8@3_%ZDfzGKNDEt;y|Al`NVQ6QNKlzOCm=`o*~l4neIK4=JvY{6 zo)`IGX$B96k!3rn>(2*fEDq!iBAZ0k?fcy}r8(m-nq~#e3ioj2kSUboHIZ*b{ySiO z`THE?%bvhZ6C>X%&E?FX*XN|6uSNDP&46Q$L7W%4rZf%Fpavlumwc#b z=dM3rXjPg~^fO9xmLEl>?$0o?LVrE7YhRgiM1OJ1vRO&r(y|SE4_H3SaMqCfVZ+EV zrMZ(aXlx@Zblzn+e`>;OUl;j78GH$nJ)SRTIlKP6;s4@*d}-vCDOA?B%KMAR1*Mr{ zn@`m35!oSfVB}qq@04cp%<^O<$+P7LN_#IPyY~mQY(sX{)}A=0TW?Y9*PDf2;s`xiD1Mwlud3vx`2= z{QI`Q=QzNw6V|zX-G(PyUjNs~Vbj$ZqoT81A?%(DC{vQ^(YULE;rS+?=YWwYy^ z^8+@U!T!lxe}AtiO^@c>$Y&$piu^S4htiBoJX0%i|K(0LQYTMX*IKo4_)2LXW61dv zr}Z};utJn(l>DmF-o5RO_J2Nd!X%AA-X7a>1ZCN=G+pJ%8iMg!@iwfL^7z^qjJGV8 zBlhP+=FQT+%yE-V>vp_6a#(2w22YygH5->^jN!`2e_#5xqu0opM8t|wnnATe_p!4Q zUKZK59@v)-XaMs5{dOZP)4X~{ZIhQ6=hri6R+@XuvNH|yditA@H)R9S^*)~Bw$F*Y ztTcBKdfRnl{=Vz7u^K7Ob@KHCDs)z|9GTv+E}OTvZk}Y>p(pPQQLckabA8+<8=50( zCApxbf8yU)ngO^O_e53(rI~BcyNo!e>+-M~sAux`miEVB^FYg|D%4*^A54-Q*ufjw*dK^i~J4J?oU_PD;wlvy*4OR@PW?0PPpK zt+Zb&=h^evdUnkm7x{A;e9fP~ziVrN{4r(8SVeaKXYJ|2 z*-)A>jcg3_y9f`8e5&s=$N|PzbzMeQF{PQepWVr}d+1s5^8WgIb=d>zS!c2l|2#_{ zJA!h(u~zW5_sZL7XP3T5X=`I~U;TT|vfHBTeLI4EuxDw$YCL;Cx0WT-tOwn0d{866 zf6z)Za{qA4!IWo{9N^omE|+JVYs<2C0`hf#pU~yLWQJwhskDzjDl*{ri{ZmSk_lf2xzMvLVke95GjbcBL7(yP@Ua$_k#h&~__LS3eKNtIN{& z&hs^SPdo2(A6%O0ti1y@r?t+VW|_7uf6ev##9Ms5il4od?FPK|$XfP?$_NJ?XZbT( zyY9d7mP|+X-twD^ec=d=(p*30nR4R%_dLjQYVW~yxt!Yi%LxZzc0Y4sO5Q%}f7JJ^ z$af>JoJM)ptLwX_EIXLkn=yAuS|J|6JCx?>%Dk&_e`4Lo z*(=D~mwE3$pDz4aX@8Dk;y%pFqBnQFZFHzK--h#%vh3)79w2#JEiVQ7r=;ff_bHLL z)w63p&9?r4br1dBcBOedHhUHCDa})I3kLK;ZjZb>vdNI^{bR53T9d>!?^5^Uv&-o% zjMwFc+MldCCY=CMD{Vg5l8?2{f9qSmL>`G;6uDx~oH>g}S*X%n2J8^oJ(4rkUL1Kz zWS7X?mU3r#?u}fViSpb%#rNAkUUSQ+ckZg9_Ix&qyf8AqCg*A7XRuxU+d7fkVn0o} zr^d>wwE>6&V&nL6S|q>BVym&GEB^hF%OY3B!SK{{-n3o!WnO7(2yrpRX^-;RUexnWjbuf6lEofUky$ev@(89mP|y}_l)dLg|E{lr*vhR+Ir zN95MXoulq~z?x=GZQb7SZ=$j-n(hi?eTT=7 zoL!e=1Pf}i+qkgr|BF> Date: Sun, 24 Jul 2016 19:48:22 +0100 Subject: [PATCH 20/22] Tweaked the file name that tracks the world type screen. --- src/main/java/rtg/event/WorldTypeMessageEventHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/rtg/event/WorldTypeMessageEventHandler.java b/src/main/java/rtg/event/WorldTypeMessageEventHandler.java index dbd77e1da..8376117f7 100644 --- a/src/main/java/rtg/event/WorldTypeMessageEventHandler.java +++ b/src/main/java/rtg/event/WorldTypeMessageEventHandler.java @@ -34,7 +34,7 @@ public void openCreateWorld(GuiOpenEvent event) { if (event.gui instanceof GuiCreateWorld) { - File nameHashFile = new File(Minecraft.getMinecraft().mcDataDir.getPath() + File.separator + "RTGChecks".hashCode()); + File nameHashFile = new File(Minecraft.getMinecraft().mcDataDir.getPath() + File.separator + "settings.rtg"); String nameHash = "" + Minecraft.getMinecraft().getSession().func_148256_e().hashCode(); try From 9ff1ad43982f796f13d7cd60aaa4e6e82c052d53 Mon Sep 17 00:00:00 2001 From: WhichOnesPink Date: Sun, 24 Jul 2016 21:08:56 +0100 Subject: [PATCH 21/22] Re-surfaced vanilla Desert M. --- .../vanilla/RealisticBiomeVanillaDesertM.java | 5 +- .../vanilla/SurfaceVanillaDesertM.java | 248 +++++++++--------- 2 files changed, 129 insertions(+), 124 deletions(-) diff --git a/src/main/java/rtg/world/biome/realistic/vanilla/RealisticBiomeVanillaDesertM.java b/src/main/java/rtg/world/biome/realistic/vanilla/RealisticBiomeVanillaDesertM.java index 71b58f052..42b3b239b 100755 --- a/src/main/java/rtg/world/biome/realistic/vanilla/RealisticBiomeVanillaDesertM.java +++ b/src/main/java/rtg/world/biome/realistic/vanilla/RealisticBiomeVanillaDesertM.java @@ -6,6 +6,7 @@ import net.minecraft.init.Blocks; import net.minecraft.world.World; import net.minecraft.world.biome.BiomeGenBase; + import rtg.api.biome.BiomeConfig; import rtg.util.CellNoise; import rtg.util.OpenSimplexNoise; @@ -31,7 +32,9 @@ public RealisticBiomeVanillaDesertM(BiomeConfig config) mutationBiome, BiomeGenBase.river, new TerrainVanillaDesertM(10f, 20f, 68f, 200f), - new SurfaceVanillaDesertM(config, Blocks.sand, (byte)0, Blocks.sandstone, (byte)0, 0)); + new SurfaceVanillaDesertM(config, Blocks.sand, Blocks.sandstone, false, null, 0.95f) + ); + this.waterSurfaceLakeChance = 0; this.noLakes=true; diff --git a/src/main/java/rtg/world/gen/surface/vanilla/SurfaceVanillaDesertM.java b/src/main/java/rtg/world/gen/surface/vanilla/SurfaceVanillaDesertM.java index f27fec5bd..dd45c73ef 100755 --- a/src/main/java/rtg/world/gen/surface/vanilla/SurfaceVanillaDesertM.java +++ b/src/main/java/rtg/world/gen/surface/vanilla/SurfaceVanillaDesertM.java @@ -2,148 +2,150 @@ import java.util.Random; +import net.minecraft.block.Block; +import net.minecraft.init.Blocks; +import net.minecraft.world.World; +import net.minecraft.world.biome.BiomeGenBase; + import rtg.api.biome.BiomeConfig; import rtg.util.CellNoise; import rtg.util.CliffCalculator; import rtg.util.OpenSimplexNoise; import rtg.world.gen.surface.SurfaceBase; -import net.minecraft.block.Block; -import net.minecraft.init.Blocks; -import net.minecraft.world.World; -import net.minecraft.world.biome.BiomeGenBase; - public class SurfaceVanillaDesertM extends SurfaceBase { - private int[] claycolor = new int[100]; - private int grassRaise = 0; - - public SurfaceVanillaDesertM(BiomeConfig config, Block top, byte topByte, Block fill, byte fillByte, int grassHeight) + private boolean beach; + private Block beachBlock; + private float min; + + private float sCliff = 1.5f; + private float sHeight = 60f; + private float sStrength = 65f; + private float cCliff = 1.5f; + + public SurfaceVanillaDesertM(BiomeConfig config, Block top, Block fill, boolean genBeach, Block genBeachBlock, float minCliff) { - super(config, top, topByte, fill, fillByte); - grassRaise = grassHeight; - - int[] c = new int[]{1, 8, 0}; - OpenSimplexNoise simplex = new OpenSimplexNoise(2L); - - float n; - for(int i = 0; i < 100; i++) - { - n = simplex.noise1(i / 3f) * 3f + simplex.noise1(i / 1f) * 0.3f + 1.5f; - n = n >= 3f ? 2.9f : n < 0f ? 0f : n; - claycolor[i] = c[(int)n]; - } + super(config, top, (byte)0, fill, (byte)0); + beach = genBeach; + beachBlock = genBeachBlock; + min = minCliff; } - - public byte getClayColorForHeight(int k) + + public SurfaceVanillaDesertM(BiomeConfig config, Block top, Block fill, boolean genBeach, Block genBeachBlock, float minCliff, float stoneCliff, float stoneHeight, float stoneStrength, float clayCliff) { - k -= 60; - k = k < 0 ? 0 : k > 99 ? 99 : k; - return (claycolor[k] == 0) ? (byte)12 : ((claycolor[k] == 1) ? (byte)0 : (byte)claycolor[k]); + this(config, top, fill, genBeach, genBeachBlock, minCliff); + + sCliff = stoneCliff; + sHeight = stoneHeight; + sStrength = stoneStrength; + cCliff = clayCliff; } - + @Override public void paintTerrain(Block[] blocks, byte[] metadata, int i, int j, int x, int y, int depth, World world, Random rand, OpenSimplexNoise simplex, CellNoise cell, float[] noise, float river, BiomeGenBase[] base) { float c = CliffCalculator.calc(x, y, noise); - boolean cliff = c > 1.3f ? true : false; - + int cliff = 0; + boolean gravel = false; + + Block b; for(int k = 255; k > -1; k--) { - Block b = blocks[(y * 16 + x) * 256 + k]; - if(b == Blocks.air) - { - depth = -1; - } - else if(b == Blocks.stone) - { - depth++; + b = blocks[(y * 16 + x) * 256 + k]; + if(b == Blocks.air) + { + depth = -1; + } + else if(b == Blocks.stone) + { + depth++; + + if(depth == 0) + { + if(k < 63) + { + if(beach) + { + gravel = true; + } + } + + float p = simplex.noise3(i / 8f, j / 8f, k / 8f) * 0.5f; + if(c > min && c > sCliff - ((k - sHeight) / sStrength) + p) + { + cliff = 1; + } + if(c > cCliff) + { + cliff = 2; + } + + if(cliff == 1) + { + if (rand.nextInt(3) == 0) { - if(k > 110) - { - blocks[(y * 16 + x) * 256 + k] = Blocks.stained_hardened_clay; - metadata[(y * 16 + x) * 256 + k] = getClayColorForHeight(k); - } - else if(depth > -1 && depth < 12) - { - if(cliff) - { - blocks[(y * 16 + x) * 256 + k] = Blocks.stained_hardened_clay; - metadata[(y * 16 + x) * 256 + k] = getClayColorForHeight(k); - } - else - { - if(depth > 4) - { - blocks[(y * 16 + x) * 256 + k] = Blocks.stained_hardened_clay; - metadata[(y * 16 + x) * 256 + k] = getClayColorForHeight(k); - } - else if(k > 74 + grassRaise) - { + blocks[(y * 16 + x) * 256 + k] = hcCobble(world, i, j, x, y, k); + metadata[(y * 16 + x) * 256 + k] = hcCobbleMeta(world, i, j, x, y, k); + } + else { - if(depth == 0) - { - blocks[(y * 16 + x) * 256 + k] = topBlock; - metadata[(y * 16 + x) * 256 + k] = topBlockMeta; - } - else - { - blocks[(y * 16 + x) * 256 + k] = fillerBlock; - metadata[(y * 16 + x) * 256 + k] = fillerBlockMeta; - } - } - else if(k < 62) - { - blocks[(y * 16 + x) * 256 + k] = fillerBlock; - metadata[(y * 16 + x) * 256 + k] = fillerBlockMeta; - } - else if(k < 62 + grassRaise) - { - if(depth == 0) - { - blocks[(y * 16 + x) * 256 + k] = topBlock; - metadata[(y * 16 + x) * 256 + k] = topBlockMeta; - } - else - { - blocks[(y * 16 + x) * 256 + k] = fillerBlock; - metadata[(y * 16 + x) * 256 + k] = fillerBlockMeta; - } - } - else if(k < 75 + grassRaise) - { - if(depth == 0) - { - blocks[(y * 16 + x) * 256 + k] = topBlock; - metadata[(y * 16 + x) * 256 + k] = topBlockMeta; - } - else - { - blocks[(y * 16 + x) * 256 + k] = fillerBlock; - metadata[(y * 16 + x) * 256 + k] = fillerBlockMeta; - } - } - else - { - if(depth == 0) - { - blocks[(y * 16 + x) * 256 + k] = topBlock; - metadata[(y * 16 + x) * 256 + k] = topBlockMeta; - } - else - { - blocks[(y * 16 + x) * 256 + k] = fillerBlock; - metadata[(y * 16 + x) * 256 + k] = fillerBlockMeta; - } - } - } - } - else if(k > 63) - { - blocks[(y * 16 + x) * 256 + k] = Blocks.stained_hardened_clay; - metadata[(y * 16 + x) * 256 + k] = getClayColorForHeight(k); - } - } + blocks[(y * 16 + x) * 256 + k] = hcStone(world, i, j, x, y, k); + metadata[(y * 16 + x) * 256 + k] = hcStoneMeta(world, i, j, x, y, k); + } + } + else if(cliff == 2) + { + blocks[(y * 16 + x) * 256 + k] = getShadowDesertBlock(world, i, j, x, y, k); + metadata[(y * 16 + x) * 256 + k] = getShadowDesertMeta(world, i, j, x, y, k); + } + else if(k < 63) + { + if(beach) + { + blocks[(y * 16 + x) * 256 + k] = beachBlock; + gravel = true; + } + else if(k < 62) + { + blocks[(y * 16 + x) * 256 + k] = fillerBlock; + metadata[(y * 16 + x) * 256 + k] = fillerBlockMeta; + } + else + { + blocks[(y * 16 + x) * 256 + k] = topBlock; + metadata[(y * 16 + x) * 256 + k] = topBlockMeta; + } + } + else + { + blocks[(y * 16 + x) * 256 + k] = topBlock; + metadata[(y * 16 + x) * 256 + k] = topBlockMeta; + } + } + else if(depth < 6) + { + if(cliff == 1) + { + blocks[(y * 16 + x) * 256 + k] = hcStone(world, i, j, x, y, k); + metadata[(y * 16 + x) * 256 + k] = hcStoneMeta(world, i, j, x, y, k); + } + else if(cliff == 2) + { + blocks[(y * 16 + x) * 256 + k] = getShadowDesertBlock(world, i, j, x, y, k); + metadata[(y * 16 + x) * 256 + k] = getShadowDesertMeta(world, i, j, x, y, k); + } + else if(gravel) + { + blocks[(y * 16 + x) * 256 + k] = beachBlock; + } + else + { + blocks[(y * 16 + x) * 256 + k] = fillerBlock; + metadata[(y * 16 + x) * 256 + k] = fillerBlockMeta; + } + } + } } } -} \ No newline at end of file +} From 5e61ca9848e7c37f0d791d4a1d798fb5b54dadb6 Mon Sep 17 00:00:00 2001 From: WhichOnesPink Date: Sun, 24 Jul 2016 21:41:53 +0100 Subject: [PATCH 22/22] Added localisations for world type screen text. Used Google Translate for these. --- src/main/resources/assets/rtg/lang/da_DK.lang | 12 ++++++------ src/main/resources/assets/rtg/lang/de_DE.lang | 12 ++++++------ src/main/resources/assets/rtg/lang/es_ES.lang | 12 ++++++------ src/main/resources/assets/rtg/lang/fr_FR.lang | 12 ++++++------ src/main/resources/assets/rtg/lang/it_IT.lang | 12 ++++++------ src/main/resources/assets/rtg/lang/ko_KR.lang | 12 ++++++------ src/main/resources/assets/rtg/lang/pt_PT.lang | 12 ++++++------ src/main/resources/assets/rtg/lang/ru_RU.lang | 12 ++++++------ src/main/resources/assets/rtg/lang/zh_CN.lang | 12 ++++++------ 9 files changed, 54 insertions(+), 54 deletions(-) diff --git a/src/main/resources/assets/rtg/lang/da_DK.lang b/src/main/resources/assets/rtg/lang/da_DK.lang index e4163ca83..0ec8ba0e1 100644 --- a/src/main/resources/assets/rtg/lang/da_DK.lang +++ b/src/main/resources/assets/rtg/lang/da_DK.lang @@ -1,8 +1,8 @@ generator.RTG=Realistisk -warning.rtgStartup1=Realistic Terrain Generation uses a custom world type. -warning.rtgStartup2=If you want realistic terrain, keep clicking the 'World Type' button -warning.rtgStartup3=under 'More World Options' until it displays 'Realistic'. -warning.rtgStartup4=The world type can be used on servers by changing the 'level-type' in -warning.rtgStartup5=server.properties to 'RTG' (without quotes). -warning.rtgStartup6=This message will only display once. +warning.rtgStartup1=Realistisk Terrain Generation bruger et tilpasset verden type. +warning.rtgStartup2=Hvis du vil have realistiske terræn, holde klikke på knappen World Type +warning.rtgStartup3=under Flere verden Options indtil det viser "Realistisk". +warning.rtgStartup4=Verdens type kan bruges på servere ved at ændre "niveau-type" i +warning.rtgStartup5=server.properties til 'RTG "(uden anførselstegn). +warning.rtgStartup6=Denne meddelelse vises kun én gang. diff --git a/src/main/resources/assets/rtg/lang/de_DE.lang b/src/main/resources/assets/rtg/lang/de_DE.lang index bbcc73651..1ab1a20a9 100644 --- a/src/main/resources/assets/rtg/lang/de_DE.lang +++ b/src/main/resources/assets/rtg/lang/de_DE.lang @@ -1,8 +1,8 @@ generator.RTG=Realistisch -warning.rtgStartup1=Realistic Terrain Generation uses a custom world type. -warning.rtgStartup2=If you want realistic terrain, keep clicking the 'World Type' button -warning.rtgStartup3=under 'More World Options' until it displays 'Realistic'. -warning.rtgStartup4=The world type can be used on servers by changing the 'level-type' in -warning.rtgStartup5=server.properties to 'RTG' (without quotes). -warning.rtgStartup6=This message will only display once. +warning.rtgStartup1=Realistische Terrain-Generation verwendet eine benutzerdefinierte Welt Typ. +warning.rtgStartup2=Wenn Sie realistisch Gelände wollen, halten Sie die 'World Type' Button +warning.rtgStartup3=unter Weitere Welt Optionen klicken, bis sie Realistisch anzeigt. +warning.rtgStartup4=Die Welt-Typ kann durch Änderung der "Level-type 'auf Servern verwendet werden, in +warning.rtgStartup5=server.properties zu" RTG "(ohne Anführungszeichen). +warning.rtgStartup6=Diese Meldung wird nur einmal angezeigt werden soll. diff --git a/src/main/resources/assets/rtg/lang/es_ES.lang b/src/main/resources/assets/rtg/lang/es_ES.lang index 6309b67bf..a8a62b9b0 100644 --- a/src/main/resources/assets/rtg/lang/es_ES.lang +++ b/src/main/resources/assets/rtg/lang/es_ES.lang @@ -1,8 +1,8 @@ generator.RTG=Realista -warning.rtgStartup1=Realistic Terrain Generation uses a custom world type. -warning.rtgStartup2=If you want realistic terrain, keep clicking the 'World Type' button -warning.rtgStartup3=under 'More World Options' until it displays 'Realistic'. -warning.rtgStartup4=The world type can be used on servers by changing the 'level-type' in -warning.rtgStartup5=server.properties to 'RTG' (without quotes). -warning.rtgStartup6=This message will only display once. +warning.rtgStartup1=Realista Terreno generación utiliza un tipo de encargo mundo. +warning.rtgStartup2=Si quieres terreno realista, seguir haciendo clic en el botón Tipo de Mundo +warning.rtgStartup3=en Más Opciones Mundial hasta que aparezca esa 'Realista'. +warning.rtgStartup4=El tipo de mundo se puede utilizar en los servidores cambiando el 'nivel de tipo' en +warning.rtgStartup5=server.properties a 'RTG' (sin comillas). +warning.rtgStartup6=Este mensaje sólo se mostrará una vez. diff --git a/src/main/resources/assets/rtg/lang/fr_FR.lang b/src/main/resources/assets/rtg/lang/fr_FR.lang index 74ca53ae6..665e9ebbc 100644 --- a/src/main/resources/assets/rtg/lang/fr_FR.lang +++ b/src/main/resources/assets/rtg/lang/fr_FR.lang @@ -1,8 +1,8 @@ generator.RTG=Réaliste -warning.rtgStartup1=Realistic Terrain Generation uses a custom world type. -warning.rtgStartup2=If you want realistic terrain, keep clicking the 'World Type' button -warning.rtgStartup3=under 'More World Options' until it displays 'Realistic'. -warning.rtgStartup4=The world type can be used on servers by changing the 'level-type' in -warning.rtgStartup5=server.properties to 'RTG' (without quotes). -warning.rtgStartup6=This message will only display once. +warning.rtgStartup1=Réaliste Generation Terrain utilise un type de monde personnalisé. +warning.rtgStartup2=Si vous voulez un terrain réaliste, garder en cliquant sur le bouton Type du Monde +warning.rtgStartup3=sous Plus d'options du monde jusqu'à ce qu'il affiche 'Réaliste'. +warning.rtgStartup4=Le type de monde peut être utilisé sur les serveurs en changeant le type de niveau dans +warning.rtgStartup5=server.properties à « RTG »(sans les guillemets). +warning.rtgStartup6=Ce message n'affichera une fois. diff --git a/src/main/resources/assets/rtg/lang/it_IT.lang b/src/main/resources/assets/rtg/lang/it_IT.lang index 266248a7a..310cd8985 100644 --- a/src/main/resources/assets/rtg/lang/it_IT.lang +++ b/src/main/resources/assets/rtg/lang/it_IT.lang @@ -1,8 +1,8 @@ generator.RTG=Realistico -warning.rtgStartup1=Realistic Terrain Generation uses a custom world type. -warning.rtgStartup2=If you want realistic terrain, keep clicking the 'World Type' button -warning.rtgStartup3=under 'More World Options' until it displays 'Realistic'. -warning.rtgStartup4=The world type can be used on servers by changing the 'level-type' in -warning.rtgStartup5=server.properties to 'RTG' (without quotes). -warning.rtgStartup6=This message will only display once. +warning.rtgStartup1=Realistico Terreno generazione utilizza un tipo di mondo personalizzato. +warning.rtgStartup2=Se si desidera terreno realistico, continuare a fare clic sul pulsante 'Tipo Mondiale' +warning.rtgStartup3=sotto 'Altre opzioni mondo' fino a quando mostra 'Realistico'. +warning.rtgStartup4=Il tipo di mondo può essere utilizzato su server modificando il 'livello di tipo' in +warning.rtgStartup5=server.properties a 'RTG' (senza virgolette). +warning.rtgStartup6=Questo messaggio verrà visualizzato solo una volta. diff --git a/src/main/resources/assets/rtg/lang/ko_KR.lang b/src/main/resources/assets/rtg/lang/ko_KR.lang index 49337d45a..e95c494e8 100644 --- a/src/main/resources/assets/rtg/lang/ko_KR.lang +++ b/src/main/resources/assets/rtg/lang/ko_KR.lang @@ -1,8 +1,8 @@ generator.RTG=현실적인 바이옴 -warning.rtgStartup1=Realistic Terrain Generation uses a custom world type. -warning.rtgStartup2=If you want realistic terrain, keep clicking the 'World Type' button -warning.rtgStartup3=under 'More World Options' until it displays 'Realistic'. -warning.rtgStartup4=The world type can be used on servers by changing the 'level-type' in -warning.rtgStartup5=server.properties to 'RTG' (without quotes). -warning.rtgStartup6=This message will only display once. +warning.rtgStartup1=현실적인 지형 생성 사용자 지정 세계 유형을 사용합니다. +warning.rtgStartup2=당신이 실제 지형을 원한다면, 그것은 '현실'이 표시 될 때까지 +warning.rtgStartup3='더 월드 옵션'에서 '세계 유형'버튼을 클릭 유지. +warning.rtgStartup4=세계 유형 따옴표없이 'RTG'에 +warning.rtgStartup5=server.properties에서 '레벨 형'변경하여 서버에서 이용 될 수있다. +warning.rtgStartup6=이 메시지는 한 번만 표시됩니다. diff --git a/src/main/resources/assets/rtg/lang/pt_PT.lang b/src/main/resources/assets/rtg/lang/pt_PT.lang index 6309b67bf..3672aed13 100644 --- a/src/main/resources/assets/rtg/lang/pt_PT.lang +++ b/src/main/resources/assets/rtg/lang/pt_PT.lang @@ -1,8 +1,8 @@ generator.RTG=Realista -warning.rtgStartup1=Realistic Terrain Generation uses a custom world type. -warning.rtgStartup2=If you want realistic terrain, keep clicking the 'World Type' button -warning.rtgStartup3=under 'More World Options' until it displays 'Realistic'. -warning.rtgStartup4=The world type can be used on servers by changing the 'level-type' in -warning.rtgStartup5=server.properties to 'RTG' (without quotes). -warning.rtgStartup6=This message will only display once. +warning.rtgStartup1=Realistic Terrain geração usa um tipo de mundo personalizado. +warning.rtgStartup2=Se você quiser terreno realista, continue clicando no botão Tipo de Mundo +warning.rtgStartup3=em Mais Opções Mundo até que ele exibe "Realista". +warning.rtgStartup4=O tipo de mundo pode ser usado em servidores, alterando o "tipo nível 'em +warning.rtgStartup5=server.properties para" RTG "(sem aspas). +warning.rtgStartup6=Esta mensagem só será exibida uma vez. diff --git a/src/main/resources/assets/rtg/lang/ru_RU.lang b/src/main/resources/assets/rtg/lang/ru_RU.lang index 412e54b00..75044767a 100644 --- a/src/main/resources/assets/rtg/lang/ru_RU.lang +++ b/src/main/resources/assets/rtg/lang/ru_RU.lang @@ -1,8 +1,8 @@ generator.RTG=Реалистичный -warning.rtgStartup1=Realistic Terrain Generation uses a custom world type. -warning.rtgStartup2=If you want realistic terrain, keep clicking the 'World Type' button -warning.rtgStartup3=under 'More World Options' until it displays 'Realistic'. -warning.rtgStartup4=The world type can be used on servers by changing the 'level-type' in -warning.rtgStartup5=server.properties to 'RTG' (without quotes). -warning.rtgStartup6=This message will only display once. +warning.rtgStartup1=Реалистичная Рельефный поколение использует пользовательский тип мира. +warning.rtgStartup2=Если вы хотите реалистичный рельеф местности, продолжайте нажимать кнопку World Type +warning.rtgStartup3=в разделе Дополнительные параметры мира, пока не появится «Реалистичный». +warning.rtgStartup4=Мир типа может использоваться на серверах за счет изменения уровня 'типа' в +warning.rtgStartup5=server.properties к "РТГ" (без кавычек). +warning.rtgStartup6=Это сообщение будет отображаться только один раз. diff --git a/src/main/resources/assets/rtg/lang/zh_CN.lang b/src/main/resources/assets/rtg/lang/zh_CN.lang index 3ebca5adf..50c13f7b9 100644 --- a/src/main/resources/assets/rtg/lang/zh_CN.lang +++ b/src/main/resources/assets/rtg/lang/zh_CN.lang @@ -1,8 +1,8 @@ generator.RTG=真实世界生成 -warning.rtgStartup1=Realistic Terrain Generation uses a custom world type. -warning.rtgStartup2=If you want realistic terrain, keep clicking the 'World Type' button -warning.rtgStartup3=under 'More World Options' until it displays 'Realistic'. -warning.rtgStartup4=The world type can be used on servers by changing the 'level-type' in -warning.rtgStartup5=server.properties to 'RTG' (without quotes). -warning.rtgStartup6=This message will only display once. +warning.rtgStartup1=真实感地形生成使用自定义的世界类型。 +warning.rtgStartup2=如果你想真实的地形,继续点击下“更多的世 +warning.rtgStartup3=界选项”直到显示“现实主义”的“世界型”按钮。 +warning.rtgStartup4=世界类型可以在服务器上通过 +warning.rtgStartup5=server.properties为“RTG”(不带引号)改变“水平型”一起使用。 +warning.rtgStartup6=此消息将只显示一次。