From ec60e0117ded20cba3972f67a4b51f8b96a672d7 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Fri, 17 Feb 2023 22:08:34 +1100 Subject: [PATCH] Add WIP plains biome --- MCGalaxy/Generator/MapGenBiome.cs | 16 +++++++++++++++- MCGalaxy/Generator/fCraft/fCraftMapGen.cs | 6 +++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/MCGalaxy/Generator/MapGenBiome.cs b/MCGalaxy/Generator/MapGenBiome.cs index b5df16d91..7dbd2bcec 100644 --- a/MCGalaxy/Generator/MapGenBiome.cs +++ b/MCGalaxy/Generator/MapGenBiome.cs @@ -22,7 +22,7 @@ namespace MCGalaxy.Generator { public enum MapGenBiomeName { - Forest, Arctic, Desert, Hell, Swamp, Mine, Sandy + Forest, Arctic, Desert, Hell, Swamp, Mine, Sandy, Plains } /// Contains environment settings and the types of blocks that are used to generate a map @@ -61,6 +61,7 @@ namespace MCGalaxy.Generator case MapGenBiomeName.Swamp: return Swamp; case MapGenBiomeName.Mine: return Mine; case MapGenBiomeName.Sandy: return Sandy; + case MapGenBiomeName.Plains: return Plains; } return Forest; } @@ -170,5 +171,18 @@ namespace MCGalaxy.Generator Border = Block.Sand, TreeType = "Palm", }; + + public static MapGenBiome Plains = new MapGenBiome() + { + Surface = Block.Grass, + Ground = Block.Dirt, + Cliff = Block.Stone, + Water = Block.Air, + Bedrock = Block.Stone, + BeachSandy = Block.Grass, + BeachRocky = Block.Grass, + TreeType = "", // "use default for generator" + Horizon = Block.Grass, + }; } } \ No newline at end of file diff --git a/MCGalaxy/Generator/fCraft/fCraftMapGen.cs b/MCGalaxy/Generator/fCraft/fCraftMapGen.cs index ec9ec6603..c3b20e6fc 100644 --- a/MCGalaxy/Generator/fCraft/fCraftMapGen.cs +++ b/MCGalaxy/Generator/fCraft/fCraftMapGen.cs @@ -58,6 +58,7 @@ namespace MCGalaxy.Generator.fCraft { bCliff = biome.Cliff; args.AddWater = biome.Water != Block.Air; + args.AddTrees = biome.TreeType != null; // TODO: temp hack, need a better solution if (args.Biome == MapGenBiomeName.Arctic) groundThickness = 1; @@ -351,8 +352,8 @@ namespace MCGalaxy.Generator.fCraft { if( (map.GetBlock( (ushort)nx, (ushort)ny, (ushort)nz ) == bGroundSurface) && slopemap[nx * length + nz] < .5 ) { // Pick a random height for the tree between Min and Max, // discarding this tree if it would breach the top of the map - int nh; - if( (nh = rn.Next( minHeight, maxHeight + 1 )) + ny + nh / 2 > map.Height ) + int nh = rn.Next( minHeight, maxHeight + 1 ); + if( ny + nh + nh / 2 > map.Height ) continue; // Generate the trunk of the tree @@ -413,7 +414,6 @@ namespace MCGalaxy.Generator.fCraft { args.SnowAltitude = (int)Math.Round(args.SnowAltitude * ratio); args.Biome = theme; - args.AddTrees = theme == MapGenBiomeName.Forest; args.WaterLevel = (lvl.Height - 1) / 2; new fCraftMapGen(args).Generate(lvl);