From 3adbbc0c0eb2652e23a473abf10590a880a85e07 Mon Sep 17 00:00:00 2001 From: dags- Date: Thu, 18 Jun 2020 10:03:21 +0100 Subject: [PATCH] - split biome/terrain locate-s into sub commands to avoid biome ids clashing with terrain type names (badlands for example) - improved detection of the y value to teleport to after /terra locate-ing - fixed bryce name - remove red sand from sediment tag - finally fixed vines on jungle trees breaking bamboo --- Engine | 2 +- FeatureManager | 2 +- .../assets/terraforged/lang/en_us.json | 3 +- src/main/java/com/terraforged/TerraWorld.java | 1 + .../biome/{Brice.java => Bryce.java} | 6 +-- .../java/com/terraforged/biome/ModBiomes.java | 2 +- .../biome/modifier/SandBiomeModifier.java | 2 +- .../terraforged/chunk/TerraSetupFactory.java | 2 +- .../com/terraforged/command/TerraCommand.java | 44 ++++++++++--------- .../command/search/BiomeSearchTask.java | 26 +++++------ .../command/search/ChunkGeneratorSearch.java | 30 +++++++++++++ .../command/search/TerrainSearchTask.java | 23 +++------- .../data/forge/tags/blocks/wg_sediment.json | 3 +- 13 files changed, 83 insertions(+), 63 deletions(-) rename src/main/java/com/terraforged/biome/{Brice.java => Bryce.java} (96%) create mode 100644 src/main/java/com/terraforged/command/search/ChunkGeneratorSearch.java diff --git a/Engine b/Engine index 4fe42cd..fd12dc3 160000 --- a/Engine +++ b/Engine @@ -1 +1 @@ -Subproject commit 4fe42cd41dd112604ef2879a43f8cfbc1a40e0fa +Subproject commit fd12dc3d3913ca610da26c2d8898897647877aa2 diff --git a/FeatureManager b/FeatureManager index 06ee44f..11ec92c 160000 --- a/FeatureManager +++ b/FeatureManager @@ -1 +1 @@ -Subproject commit 06ee44f3e14bf99f2115f1102645b063ae6ac697 +Subproject commit 11ec92c8c103ddd1a30edcf0376f6270320e37d8 diff --git a/generated/resources/assets/terraforged/lang/en_us.json b/generated/resources/assets/terraforged/lang/en_us.json index 09a36fc..6ae4347 100644 --- a/generated/resources/assets/terraforged/lang/en_us.json +++ b/generated/resources/assets/terraforged/lang/en_us.json @@ -1,7 +1,6 @@ { - "biome.terraforged.brice": "Brice", + "biome.terraforged.bryce": "Bryce", "biome.terraforged.cold_steppe": "Cold Steppe", - "biome.terraforged.dunes": "Dunes", "biome.terraforged.fir_forest": "Fir Forest", "biome.terraforged.flower_plains": "Flower Plains", "biome.terraforged.frozen_lake": "Frozen Lake", diff --git a/src/main/java/com/terraforged/TerraWorld.java b/src/main/java/com/terraforged/TerraWorld.java index 304e4cc..da0a882 100644 --- a/src/main/java/com/terraforged/TerraWorld.java +++ b/src/main/java/com/terraforged/TerraWorld.java @@ -124,6 +124,7 @@ public class TerraWorld extends WorldType { public static void init() { Log.info("Registered world type"); new TerraWorld("terraforged", TerraChunkGenerator::new); + if (Environment.isDev()) { Log.info("Registered developer world type"); new TerraWorld("terratest", TestChunkGenerator::new); diff --git a/src/main/java/com/terraforged/biome/Brice.java b/src/main/java/com/terraforged/biome/Bryce.java similarity index 96% rename from src/main/java/com/terraforged/biome/Brice.java rename to src/main/java/com/terraforged/biome/Bryce.java index c07fe0e..775eb16 100644 --- a/src/main/java/com/terraforged/biome/Brice.java +++ b/src/main/java/com/terraforged/biome/Bryce.java @@ -12,11 +12,11 @@ import net.minecraft.world.gen.feature.structure.MineshaftConfig; import net.minecraft.world.gen.feature.structure.MineshaftStructure; import net.minecraft.world.gen.surfacebuilders.SurfaceBuilder; -public class Brice extends BiomeVariant { +public class Bryce extends BiomeVariant { - public Brice() { + public Bryce() { super((new Biome.Builder()).surfaceBuilder(SurfaceBuilder.BADLANDS, SurfaceBuilder.RED_SAND_WHITE_TERRACOTTA_GRAVEL_CONFIG).precipitation(Biome.RainType.NONE).category(Biome.Category.MESA).depth(0.1F).scale(0.2F).temperature(2.0F).downfall(0.0F).waterColor(4159204).waterFogColor(329011).parent((String)null)); - setRegistryName("terraforged", "brice"); + setRegistryName("terraforged", "bryce"); this.addStructure(Feature.MINESHAFT.withConfiguration(new MineshaftConfig(0.004D, MineshaftStructure.Type.MESA))); this.addStructure(Feature.STRONGHOLD.withConfiguration(IFeatureConfig.NO_FEATURE_CONFIG)); DefaultBiomeFeatures.addCarvers(this); diff --git a/src/main/java/com/terraforged/biome/ModBiomes.java b/src/main/java/com/terraforged/biome/ModBiomes.java index 2b6aca0..13d4bd7 100644 --- a/src/main/java/com/terraforged/biome/ModBiomes.java +++ b/src/main/java/com/terraforged/biome/ModBiomes.java @@ -39,7 +39,7 @@ public class ModBiomes { private static final ArrayList biomes = new ArrayList<>(); - public static final Biome BRICE = register(new Brice()); + public static final Biome BRYCE = register(new Bryce()); public static final Biome COLD_STEPPE = register(new ColdSteppe()); public static final Biome FIR_FOREST = register(new FirForest()); public static final Biome FLOWER_PLAINS = register(new FlowerPlains()); diff --git a/src/main/java/com/terraforged/biome/modifier/SandBiomeModifier.java b/src/main/java/com/terraforged/biome/modifier/SandBiomeModifier.java index e7bda85..03cd08b 100644 --- a/src/main/java/com/terraforged/biome/modifier/SandBiomeModifier.java +++ b/src/main/java/com/terraforged/biome/modifier/SandBiomeModifier.java @@ -40,7 +40,7 @@ public class SandBiomeModifier extends AbstractMaxHeightModifier { private final Set biomes; public SandBiomeModifier(TerraContext context) { - super(context.seed, context.factory.getClimate(), 10, 1, context.levels.scale(8), context.levels.ground(10), context.levels.ground(25)); + super(context.seed, context.factory.getClimate(), 16, 2, context.levels.scale(24), context.levels.ground(24), context.levels.ground(48)); this.biomes = ForgeRegistries.BIOMES.getValues().stream() .filter(biome -> context.materials.isSand(biome.getSurfaceBuilderConfig().getTop().getBlock())) .collect(Collectors.toSet()); diff --git a/src/main/java/com/terraforged/chunk/TerraSetupFactory.java b/src/main/java/com/terraforged/chunk/TerraSetupFactory.java index 2dee4f1..0ea1c39 100644 --- a/src/main/java/com/terraforged/chunk/TerraSetupFactory.java +++ b/src/main/java/com/terraforged/chunk/TerraSetupFactory.java @@ -111,7 +111,7 @@ public class TerraSetupFactory { SurfaceManager manager = new SurfaceManager(); manager.replace(Biomes.DEEP_FROZEN_OCEAN.delegate.get(), new IcebergsSurface(context, 30, 30)); manager.replace(Biomes.FROZEN_OCEAN.delegate.get(), new IcebergsSurface(context, 20, 15)); - manager.append(ModBiomes.BRICE, new BriceSurface(context.seed)); + manager.append(ModBiomes.BRYCE, new BriceSurface(context.seed)); manager.replace( new SwampSurface(), Biomes.SWAMP.delegate.get(), diff --git a/src/main/java/com/terraforged/command/TerraCommand.java b/src/main/java/com/terraforged/command/TerraCommand.java index c823634..cd15548 100644 --- a/src/main/java/com/terraforged/command/TerraCommand.java +++ b/src/main/java/com/terraforged/command/TerraCommand.java @@ -63,11 +63,11 @@ import net.minecraft.util.text.TextFormatting; import net.minecraft.util.text.TranslationTextComponent; import net.minecraft.util.text.event.ClickEvent; import net.minecraft.util.text.event.HoverEvent; -import net.minecraft.world.IWorldReader; import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.ColumnFuzzedBiomeMagnifier; import net.minecraft.world.dimension.DimensionType; import net.minecraft.world.gen.ChunkGenerator; +import net.minecraft.world.server.ServerWorld; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.server.FMLServerStartingEvent; @@ -109,14 +109,16 @@ public class TerraCommand { .then(Commands.literal("debug") .executes(TerraCommand::debugBiome)) .then(Commands.literal("locate") - .then(Commands.argument("biome", BiomeArgType.biome()) - .executes(TerraCommand::findBiome) - .then(Commands.argument("terrain", TerrainArgType.terrain()) - .executes(TerraCommand::findTerrainAndBiome))) - .then(Commands.argument("terrain", TerrainArgType.terrain()) - .executes(TerraCommand::findTerrain) + .then(Commands.literal("biome") .then(Commands.argument("biome", BiomeArgType.biome()) - .executes(TerraCommand::findTerrainAndBiome)))); + .executes(TerraCommand::findBiome))) + .then(Commands.literal("terrain") + .then(Commands.argument("terrain", TerrainArgType.terrain()) + .executes(TerraCommand::findTerrain))) + .then(Commands.literal("both") + .then(Commands.argument("biome", BiomeArgType.biome()) + .then(Commands.argument("terrain", TerrainArgType.terrain()) + .executes(TerraCommand::findTerrainAndBiome))))); } private static int query(CommandContext context) throws CommandSyntaxException { @@ -165,7 +167,6 @@ public class TerraCommand { ServerPlayerEntity player = context.getSource().asPlayer(); BlockPos position = player.getPosition(); int x = position.getX(); - int y = position.getY(); int z = position.getZ(); long seed = player.getServerWorld().getSeed(); @@ -189,13 +190,12 @@ public class TerraCommand { )); Terrain terrain = TerrainArgType.getTerrain(context, "terrain"); - Terrain target = getTerrainInstance(terrain, terraContext.terrain); + Terrain type = getTerrainInstance(terrain, terraContext.terrain); BlockPos pos = context.getSource().asPlayer().getPosition(); UUID playerID = context.getSource().asPlayer().getUniqueID(); MinecraftServer server = context.getSource().getServer(); - WorldGenerator worldGenerator = terraContext.factory.get(); - IWorldReader reader = context.getSource().asPlayer().getServerWorld(); - Search search = new TerrainSearchTask(pos, reader, worldGenerator, target); + WorldGenerator generator = terraContext.factory.get(); + Search search = new TerrainSearchTask(pos, type, getChunkGenerator(context), generator); doSearch(server, playerID, search); context.getSource().sendFeedback(new StringTextComponent("Searching..."), false); @@ -204,7 +204,7 @@ public class TerraCommand { private static int findBiome(CommandContext context) throws CommandSyntaxException { // get the generator's context - TerraContext terraContext = getContext(context).orElseThrow(() -> createException( + getContext(context).orElseThrow(() -> createException( "Invalid world type", "This command can only be run in a TerraForged world!" )); @@ -213,8 +213,8 @@ public class TerraCommand { BlockPos pos = context.getSource().asPlayer().getPosition(); UUID playerID = context.getSource().asPlayer().getUniqueID(); MinecraftServer server = context.getSource().getServer(); - IWorldReader reader = context.getSource().asPlayer().getServerWorld(); - Search search = new BiomeSearchTask(pos, reader, biome); + ServerWorld world = context.getSource().asPlayer().getServerWorld(); + Search search = new BiomeSearchTask(pos, biome, world.getChunkProvider().getChunkGenerator(), getBiomeProvider(context)); doSearch(server, playerID, search); context.getSource().sendFeedback(new StringTextComponent("Searching..."), false); @@ -232,13 +232,11 @@ public class TerraCommand { Terrain target = getTerrainInstance(terrain, terraContext.terrain); Biome biome = BiomeArgType.getBiome(context, "biome"); BlockPos pos = context.getSource().asPlayer().getPosition(); - IWorldReader world = context.getSource().asPlayer().getServerWorld(); UUID playerID = context.getSource().asPlayer().getUniqueID(); MinecraftServer server = context.getSource().getServer(); - WorldGenerator worldGenerator = terraContext.factory.get(); - IWorldReader reader = context.getSource().asPlayer().getServerWorld(); - Search biomeSearch = new BiomeSearchTask(pos, world, biome); - Search terrainSearch = new TerrainSearchTask(pos, reader, worldGenerator, target); + WorldGenerator generator = terraContext.factory.get(); + Search biomeSearch = new BiomeSearchTask(pos, biome, getChunkGenerator(context), getBiomeProvider(context)); + Search terrainSearch = new TerrainSearchTask(pos, target, getChunkGenerator(context), generator); Search search = new BothSearchTask(pos, biomeSearch, terrainSearch); doSearch(server, playerID, search); context.getSource().sendFeedback(new StringTextComponent("Searching..."), false); @@ -290,6 +288,10 @@ public class TerraCommand { return find; } + private static ChunkGenerator getChunkGenerator(CommandContext context) { + return context.getSource().getWorld().getChunkProvider().getChunkGenerator(); + } + private static BiomeProvider getBiomeProvider(CommandContext context) { return (BiomeProvider) context.getSource().getWorld().getChunkProvider().getChunkGenerator().getBiomeProvider(); } diff --git a/src/main/java/com/terraforged/command/search/BiomeSearchTask.java b/src/main/java/com/terraforged/command/search/BiomeSearchTask.java index 9a99b8a..61a1c12 100644 --- a/src/main/java/com/terraforged/command/search/BiomeSearchTask.java +++ b/src/main/java/com/terraforged/command/search/BiomeSearchTask.java @@ -1,18 +1,21 @@ package com.terraforged.command.search; +import com.terraforged.biome.provider.BiomeProvider; +import com.terraforged.core.cell.Cell; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IWorldReader; import net.minecraft.world.biome.Biome; -import net.minecraft.world.gen.Heightmap; +import net.minecraft.world.gen.ChunkGenerator; -public class BiomeSearchTask extends Search { +public class BiomeSearchTask extends ChunkGeneratorSearch { private final Biome biome; - private final IWorldReader reader; + private final BiomeProvider biomeProvider; - public BiomeSearchTask(BlockPos center, IWorldReader reader, Biome biome) { - super(center, 128); - this.reader = reader; + private final Cell cell = new Cell(); + + public BiomeSearchTask(BlockPos center, Biome biome, ChunkGenerator generator, BiomeProvider biomeProvider) { + super(center, generator); + this.biomeProvider = biomeProvider; this.biome = biome; } @@ -23,12 +26,7 @@ public class BiomeSearchTask extends Search { @Override public boolean test(BlockPos pos) { - return reader.getNoiseBiomeRaw(pos.getX() >> 2, pos.getY(), pos.getZ() >> 2) == biome; - } - - @Override - public BlockPos success(BlockPos.Mutable pos) { - pos.setY(reader.getHeight(Heightmap.Type.WORLD_SURFACE_WG, pos.getX(), pos.getZ())); - return super.success(pos); + biomeProvider.getWorldLookup().applyCell(cell, pos.getX(), pos.getZ()); + return biomeProvider.getBiome(cell, pos.getX(), pos.getZ()) == biome; } } diff --git a/src/main/java/com/terraforged/command/search/ChunkGeneratorSearch.java b/src/main/java/com/terraforged/command/search/ChunkGeneratorSearch.java new file mode 100644 index 0000000..f4f8dea --- /dev/null +++ b/src/main/java/com/terraforged/command/search/ChunkGeneratorSearch.java @@ -0,0 +1,30 @@ +package com.terraforged.command.search; + +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.gen.ChunkGenerator; +import net.minecraft.world.gen.Heightmap; + +public abstract class ChunkGeneratorSearch extends Search { + + private final ChunkGenerator chunkGenerator; + + public ChunkGeneratorSearch(BlockPos center, ChunkGenerator chunkGenerator) { + super(center); + this.chunkGenerator = chunkGenerator; + } + + public ChunkGeneratorSearch(BlockPos center, int minRadius, ChunkGenerator chunkGenerator) { + this(center, minRadius, MAX_RADIUS, chunkGenerator); + } + + public ChunkGeneratorSearch(BlockPos center, int minRadius, int maxRadius, ChunkGenerator chunkGenerator) { + super(center, minRadius, maxRadius); + this.chunkGenerator = chunkGenerator; + } + + @Override + public BlockPos success(BlockPos.Mutable pos) { + pos.setY(chunkGenerator.func_222529_a(pos.getX(), pos.getZ(), Heightmap.Type.WORLD_SURFACE_WG)); + return pos; + } +} diff --git a/src/main/java/com/terraforged/command/search/TerrainSearchTask.java b/src/main/java/com/terraforged/command/search/TerrainSearchTask.java index 7b6c5dc..cfa294c 100644 --- a/src/main/java/com/terraforged/command/search/TerrainSearchTask.java +++ b/src/main/java/com/terraforged/command/search/TerrainSearchTask.java @@ -4,21 +4,18 @@ import com.terraforged.core.cell.Cell; import com.terraforged.world.WorldGenerator; import com.terraforged.world.terrain.Terrain; import net.minecraft.util.math.BlockPos; -import net.minecraft.world.IWorldReader; -import net.minecraft.world.gen.Heightmap; +import net.minecraft.world.gen.ChunkGenerator; -public class TerrainSearchTask extends Search { +public class TerrainSearchTask extends ChunkGeneratorSearch { private final Terrain type; - private final IWorldReader reader; - private final WorldGenerator generator; + private final WorldGenerator worldGenerator; private final Cell cell = new Cell(); - public TerrainSearchTask(BlockPos center, IWorldReader reader, WorldGenerator generator, Terrain type) { - super(center, 256); + public TerrainSearchTask(BlockPos center, Terrain type, ChunkGenerator chunkGenerator, WorldGenerator worldGenerator) { + super(center, 256, chunkGenerator); this.type = type; - this.generator = generator; - this.reader = reader; + this.worldGenerator = worldGenerator; } @Override @@ -28,13 +25,7 @@ public class TerrainSearchTask extends Search { @Override public boolean test(BlockPos pos) { - generator.getHeightmap().apply(cell, pos.getX(), pos.getZ()); + worldGenerator.getHeightmap().apply(cell, pos.getX(), pos.getZ()); return cell.terrain == type; } - - @Override - public BlockPos success(BlockPos.Mutable pos) { - pos.setY(reader.getHeight(Heightmap.Type.WORLD_SURFACE_WG, pos.getX(), pos.getZ())); - return super.success(pos); - } } diff --git a/src/main/resources/data/forge/tags/blocks/wg_sediment.json b/src/main/resources/data/forge/tags/blocks/wg_sediment.json index f605778..90c0616 100644 --- a/src/main/resources/data/forge/tags/blocks/wg_sediment.json +++ b/src/main/resources/data/forge/tags/blocks/wg_sediment.json @@ -2,7 +2,6 @@ "replace": false, "values": [ "minecraft:sand", - "minecraft:gravel", - "minecraft:red_sand" + "minecraft:gravel" ] } \ No newline at end of file