From 2cac91c351ec15f873de5409553e244d102d9453 Mon Sep 17 00:00:00 2001 From: Sollace Date: Thu, 28 May 2020 13:40:36 +0200 Subject: [PATCH] Move structures an clean up how they're added to biomes --- .../structure/CloudDungeonFeature.java | 19 ++-------- .../unicopia/structure/RuinFeature.java | 20 ++--------- .../unicopia/structure/UStructures.java | 33 +++++++++++++++--- .../unicopia/structures/cloud/house_small.nbt | Bin .../unicopia/structures/cloud/island_tiny.nbt | Bin .../structures/cloud/temple_small.nbt | Bin .../structures/ground/temple_with_book.nbt | Bin .../structures/ground/temple_without_book.nbt | Bin .../unicopia/structures/ground/tower.nbt | Bin .../structures/ground/wizard_tower_blue.nbt | Bin .../structures/ground/wizard_tower_red.nbt | Bin 11 files changed, 34 insertions(+), 38 deletions(-) rename src/main/resources/{assets => data}/unicopia/structures/cloud/house_small.nbt (100%) rename src/main/resources/{assets => data}/unicopia/structures/cloud/island_tiny.nbt (100%) rename src/main/resources/{assets => data}/unicopia/structures/cloud/temple_small.nbt (100%) rename src/main/resources/{assets => data}/unicopia/structures/ground/temple_with_book.nbt (100%) rename src/main/resources/{assets => data}/unicopia/structures/ground/temple_without_book.nbt (100%) rename src/main/resources/{assets => data}/unicopia/structures/ground/tower.nbt (100%) rename src/main/resources/{assets => data}/unicopia/structures/ground/wizard_tower_blue.nbt (100%) rename src/main/resources/{assets => data}/unicopia/structures/ground/wizard_tower_red.nbt (100%) diff --git a/src/main/java/com/minelittlepony/unicopia/structure/CloudDungeonFeature.java b/src/main/java/com/minelittlepony/unicopia/structure/CloudDungeonFeature.java index a5a4b765..f1d36145 100644 --- a/src/main/java/com/minelittlepony/unicopia/structure/CloudDungeonFeature.java +++ b/src/main/java/com/minelittlepony/unicopia/structure/CloudDungeonFeature.java @@ -1,6 +1,5 @@ package com.minelittlepony.unicopia.structure; -import java.util.Arrays; import java.util.Random; import java.util.function.Function; @@ -19,7 +18,6 @@ import net.minecraft.util.math.BlockBox; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IWorld; import net.minecraft.world.biome.Biome; -import net.minecraft.world.biome.Biomes; import net.minecraft.world.gen.GenerationStep; import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.decorator.Decorator; @@ -37,25 +35,14 @@ class CloudDungeonFeature extends AbstractTempleFeature { new Identifier("unicopia", "cloud/island_small") }; - public CloudDungeonFeature(Function, ? extends DefaultFeatureConfig> func) { + public CloudDungeonFeature(Function, ? extends DefaultFeatureConfig> func, Biome...biomes) { super(func); - Arrays.asList( - Biomes.OCEAN, - Biomes.WOODED_BADLANDS_PLATEAU, - Biomes.DESERT, - Biomes.DESERT_HILLS, - Biomes.JUNGLE, - Biomes.JUNGLE_HILLS, - Biomes.SWAMP, - Biomes.SWAMP_HILLS, - Biomes.ICE_SPIKES, - Biomes.TAIGA - ).forEach(biome -> { + for (Biome biome : biomes) { biome.addFeature(GenerationStep.Feature.LOCAL_MODIFICATIONS, configure(FeatureConfig.DEFAULT) .createDecoratedFeature(Decorator.NOPE .configure(NopeDecoratorConfig.DEFAULT))); - }); + } } @Override diff --git a/src/main/java/com/minelittlepony/unicopia/structure/RuinFeature.java b/src/main/java/com/minelittlepony/unicopia/structure/RuinFeature.java index f50e270e..0408d740 100644 --- a/src/main/java/com/minelittlepony/unicopia/structure/RuinFeature.java +++ b/src/main/java/com/minelittlepony/unicopia/structure/RuinFeature.java @@ -1,6 +1,5 @@ package com.minelittlepony.unicopia.structure; -import java.util.Arrays; import java.util.Random; import java.util.function.Function; @@ -19,7 +18,6 @@ import net.minecraft.util.math.BlockBox; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IWorld; import net.minecraft.world.biome.Biome; -import net.minecraft.world.biome.Biomes; import net.minecraft.world.gen.GenerationStep; import net.minecraft.world.gen.chunk.ChunkGenerator; import net.minecraft.world.gen.decorator.Decorator; @@ -39,26 +37,14 @@ class RuinFeature extends AbstractTempleFeature { new Identifier("unicopia", "ground/wizard_tower_blue") }; - public RuinFeature(Function, ? extends DefaultFeatureConfig> func) { + public RuinFeature(Function, ? extends DefaultFeatureConfig> func, Biome... biomes) { super(func); - Arrays.asList( - Biomes.TAIGA, - Biomes.TAIGA_HILLS, - Biomes.GIANT_TREE_TAIGA, - Biomes.GIANT_TREE_TAIGA_HILLS, - Biomes.SNOWY_TAIGA, - Biomes.SNOWY_TAIGA_HILLS, - Biomes.GIANT_SPRUCE_TAIGA, - Biomes.GIANT_TREE_TAIGA_HILLS, - Biomes.SNOWY_TAIGA_MOUNTAINS, - Biomes.DARK_FOREST, - Biomes.DARK_FOREST_HILLS - ).forEach(biome -> { + for (Biome biome : biomes) { biome.addFeature(GenerationStep.Feature.SURFACE_STRUCTURES, configure(FeatureConfig.DEFAULT) .createDecoratedFeature(Decorator.NOPE.configure(DecoratorConfig.DEFAULT))); - }); + } } @Override diff --git a/src/main/java/com/minelittlepony/unicopia/structure/UStructures.java b/src/main/java/com/minelittlepony/unicopia/structure/UStructures.java index d09dc436..46b5f462 100644 --- a/src/main/java/com/minelittlepony/unicopia/structure/UStructures.java +++ b/src/main/java/com/minelittlepony/unicopia/structure/UStructures.java @@ -6,6 +6,7 @@ import net.minecraft.structure.StructurePieceType; import net.minecraft.util.Identifier; import net.minecraft.util.registry.Registry; import net.minecraft.world.biome.Biome; +import net.minecraft.world.biome.Biomes; import net.minecraft.world.gen.GenerationStep; import net.minecraft.world.gen.decorator.CountExtraChanceDecoratorConfig; import net.minecraft.world.gen.decorator.Decorator; @@ -19,15 +20,37 @@ public interface UStructures { StructurePieceType CLOUD_HOUSE_PART = part("cloud_house", CloudDungeonFeature.Piece::new); StructurePieceType RUIN_PART = part("ruin", RuinFeature.Piece::new); - StructureFeature CLOUD_HOUSE = feature("cloud_house", new CloudDungeonFeature(DefaultFeatureConfig::deserialize)); - StructureFeature RUIN = feature("ruin", new RuinFeature(DefaultFeatureConfig::deserialize)); + StructureFeature CLOUD_HOUSE = feature("cloud_house", new CloudDungeonFeature(DefaultFeatureConfig::deserialize, Biomes.OCEAN, + Biomes.WOODED_BADLANDS_PLATEAU, + Biomes.DESERT, + Biomes.DESERT_HILLS, + Biomes.JUNGLE, + Biomes.JUNGLE_HILLS, + Biomes.SWAMP, + Biomes.SWAMP_HILLS, + Biomes.ICE_SPIKES, + Biomes.TAIGA)); + StructureFeature RUIN = feature("ruin", new RuinFeature(DefaultFeatureConfig::deserialize, + Biomes.TAIGA, + Biomes.TAIGA_HILLS, + Biomes.GIANT_TREE_TAIGA, + Biomes.GIANT_TREE_TAIGA_HILLS, + Biomes.SNOWY_TAIGA, + Biomes.SNOWY_TAIGA_HILLS, + Biomes.GIANT_SPRUCE_TAIGA, + Biomes.GIANT_TREE_TAIGA_HILLS, + Biomes.SNOWY_TAIGA_MOUNTAINS, + Biomes.DARK_FOREST, + Biomes.DARK_FOREST_HILLS + )); static StructurePieceType part(String id, StructurePieceType type) { return Registry.register(Registry.STRUCTURE_PIECE, new Identifier("unicopia", id), type); } - static > F feature(String id, F feature) { - return Registry.register(Registry.FEATURE, new Identifier("unicopia", id), feature); + static > F feature(String name, F feature) { + Identifier id = new Identifier("unicopia", name); + return Registry.register(Registry.STRUCTURE_FEATURE, id, Registry.register(Registry.FEATURE, id, feature)); } static void bootstrap() { @@ -41,7 +64,7 @@ public interface UStructures { Feature.FANCY_TREE.configure(CustomSaplingGenerator.APPLE_TREE.fancyConfig).withChance(0.01F)), Feature.NORMAL_TREE.configure(CustomSaplingGenerator.APPLE_TREE.config) )) - .createDecoratedFeature(Decorator.COUNT_EXTRA_HEIGHTMAP.configure(new CountExtraChanceDecoratorConfig(10, 0.1F, 1)))); + .createDecoratedFeature(Decorator.COUNT_EXTRA_HEIGHTMAP.configure(new CountExtraChanceDecoratorConfig(0, 0.1F, 3)))); } }); } diff --git a/src/main/resources/assets/unicopia/structures/cloud/house_small.nbt b/src/main/resources/data/unicopia/structures/cloud/house_small.nbt similarity index 100% rename from src/main/resources/assets/unicopia/structures/cloud/house_small.nbt rename to src/main/resources/data/unicopia/structures/cloud/house_small.nbt diff --git a/src/main/resources/assets/unicopia/structures/cloud/island_tiny.nbt b/src/main/resources/data/unicopia/structures/cloud/island_tiny.nbt similarity index 100% rename from src/main/resources/assets/unicopia/structures/cloud/island_tiny.nbt rename to src/main/resources/data/unicopia/structures/cloud/island_tiny.nbt diff --git a/src/main/resources/assets/unicopia/structures/cloud/temple_small.nbt b/src/main/resources/data/unicopia/structures/cloud/temple_small.nbt similarity index 100% rename from src/main/resources/assets/unicopia/structures/cloud/temple_small.nbt rename to src/main/resources/data/unicopia/structures/cloud/temple_small.nbt diff --git a/src/main/resources/assets/unicopia/structures/ground/temple_with_book.nbt b/src/main/resources/data/unicopia/structures/ground/temple_with_book.nbt similarity index 100% rename from src/main/resources/assets/unicopia/structures/ground/temple_with_book.nbt rename to src/main/resources/data/unicopia/structures/ground/temple_with_book.nbt diff --git a/src/main/resources/assets/unicopia/structures/ground/temple_without_book.nbt b/src/main/resources/data/unicopia/structures/ground/temple_without_book.nbt similarity index 100% rename from src/main/resources/assets/unicopia/structures/ground/temple_without_book.nbt rename to src/main/resources/data/unicopia/structures/ground/temple_without_book.nbt diff --git a/src/main/resources/assets/unicopia/structures/ground/tower.nbt b/src/main/resources/data/unicopia/structures/ground/tower.nbt similarity index 100% rename from src/main/resources/assets/unicopia/structures/ground/tower.nbt rename to src/main/resources/data/unicopia/structures/ground/tower.nbt diff --git a/src/main/resources/assets/unicopia/structures/ground/wizard_tower_blue.nbt b/src/main/resources/data/unicopia/structures/ground/wizard_tower_blue.nbt similarity index 100% rename from src/main/resources/assets/unicopia/structures/ground/wizard_tower_blue.nbt rename to src/main/resources/data/unicopia/structures/ground/wizard_tower_blue.nbt diff --git a/src/main/resources/assets/unicopia/structures/ground/wizard_tower_red.nbt b/src/main/resources/data/unicopia/structures/ground/wizard_tower_red.nbt similarity index 100% rename from src/main/resources/assets/unicopia/structures/ground/wizard_tower_red.nbt rename to src/main/resources/data/unicopia/structures/ground/wizard_tower_red.nbt