From 8b7ca539b77fcdb0dab4a28b33e0567ea873393f Mon Sep 17 00:00:00 2001 From: peaceheis <69596656+peaceheis@users.noreply.github.com> Date: Thu, 28 Jul 2022 02:44:46 -0500 Subject: [PATCH 1/4] Clean Up Codebase --- .../github/debuggyteam/wonders/Wonders.java | 11 +- .../wonders/block/WondersBlocks.java | 117 ++++++++++++------ .../wonders/item/WondersItems.java | 31 +++-- .../wonders/mixin/TitleScreenMixin.java | 16 --- .../wonders/util/WondersRegistry.java | 22 ---- .../wonders/util/WondersUtils.java | 31 ----- .../world/biomes/WarmWondersBiomeCreator.java | 42 +++++++ .../wonders/world/biomes/WondersBiomes.java | 46 ++----- ...acedFeatures.java => WondersFeatures.java} | 2 +- src/main/resources/wonders.mixins.json | 1 - 10 files changed, 146 insertions(+), 173 deletions(-) delete mode 100644 src/main/java/io/github/debuggyteam/wonders/mixin/TitleScreenMixin.java delete mode 100644 src/main/java/io/github/debuggyteam/wonders/util/WondersRegistry.java create mode 100644 src/main/java/io/github/debuggyteam/wonders/world/biomes/WarmWondersBiomeCreator.java rename src/main/java/io/github/debuggyteam/wonders/world/gen/feature/{WondersVegetationPlacedFeatures.java => WondersFeatures.java} (92%) diff --git a/src/main/java/io/github/debuggyteam/wonders/Wonders.java b/src/main/java/io/github/debuggyteam/wonders/Wonders.java index 368bfea..d6d0f74 100644 --- a/src/main/java/io/github/debuggyteam/wonders/Wonders.java +++ b/src/main/java/io/github/debuggyteam/wonders/Wonders.java @@ -4,19 +4,16 @@ import io.github.debuggyteam.wonders.item.WondersItems; import io.github.debuggyteam.wonders.util.WondersUtils; import io.github.debuggyteam.wonders.world.biomes.WondersBiomes; -import io.github.debuggyteam.wonders.world.gen.feature.custom.CustomBoulder; +import io.github.debuggyteam.wonders.world.gen.feature.OreBoulder; import net.minecraft.block.Blocks; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; -import net.minecraft.util.Holder; import net.minecraft.util.Identifier; import net.minecraft.util.math.intprovider.ConstantIntProvider; import net.minecraft.util.registry.Registry; import net.minecraft.world.Heightmap; import net.minecraft.world.gen.feature.ConfiguredFeature; import net.minecraft.world.gen.feature.Feature; -import net.minecraft.world.gen.feature.PlacedFeature; -import net.minecraft.world.gen.stateprovider.BlockStateProvider; import net.minecraft.world.gen.stateprovider.SimpleBlockStateProvider; import org.quiltmc.loader.api.ModContainer; import org.quiltmc.qsl.base.api.entrypoint.ModInitializer; @@ -39,10 +36,10 @@ public static Identifier ID(String name) { return new Identifier(MOD_ID, name); } - public static final ItemGroup itemGroup = QuiltItemGroup.builder(ID("itemgroup")).icon(() -> new ItemStack(WondersItems.TEST)).build(); + public static final ItemGroup GROUP = QuiltItemGroup.builder(ID("itemgroup")).icon(() -> new ItemStack(WondersItems.TEST)).build(); - private static final Feature BOULDER = new CustomBoulder(CustomBoulder.BoulderConfig.CODEC); - public static final ConfiguredFeature ROCK = BOULDER.configure(new CustomBoulder.BoulderConfig(ConstantIntProvider.create(15), + private static final Feature BOULDER = new OreBoulder(OreBoulder.OreBoulderConfiguration.CODEC); + public static final ConfiguredFeature ROCK = BOULDER.configure(new OreBoulder.OreBoulderConfiguration(ConstantIntProvider.create(15), new SimpleBlockStateProvider(Blocks.STONE.getDefaultState()))) .decorate(Decorator.HEIGHTMAP.configure(new HeightmapDecoratorConfig(Heightmap.Type.OCEAN_FLOOR_WG))) .spreadHorizontally() diff --git a/src/main/java/io/github/debuggyteam/wonders/block/WondersBlocks.java b/src/main/java/io/github/debuggyteam/wonders/block/WondersBlocks.java index 8dcbdf9..d83f1ae 100644 --- a/src/main/java/io/github/debuggyteam/wonders/block/WondersBlocks.java +++ b/src/main/java/io/github/debuggyteam/wonders/block/WondersBlocks.java @@ -1,61 +1,100 @@ package io.github.debuggyteam.wonders.block; -import io.github.debuggyteam.wonders.util.WondersRegistry; +import io.github.debuggyteam.wonders.Wonders; +import net.fabricmc.fabric.api.registry.FlammableBlockRegistry; +import net.fabricmc.fabric.api.registry.FuelRegistry; +import net.fabricmc.fabric.api.registry.StrippableBlockRegistry; import net.minecraft.block.*; import net.minecraft.sound.BlockSoundGroup; +import net.minecraft.util.registry.Registry; import org.quiltmc.qsl.block.extensions.api.QuiltBlockSettings; +import java.util.HashMap; +import java.util.Map; + public class WondersBlocks { + /** + * Used to hold Blocks (type {@code Block}) and their names (type {@code String}) + *

+ * Used by both {@code WondersBlocks} and {@code WondersItems} to allow for automatic creation of block items per-block. + * @see io.github.debuggyteam.wonders.item.WondersItems#init + */ + public static final Map BLOCKS = new HashMap<>(); /* Made by Joost */ - public static final Block TEST_BLOCK = WondersRegistry.registerBlock("test_block", createBlock(Material.WOOD, 2.0f)); - - // Palm tree logs - public static final Block PALM_LOG = WondersRegistry.registerBlock("palm_log", new PillarBlock( - QuiltBlockSettings.copy(Blocks.OAK_LOG).sounds(BlockSoundGroup.WOOD).strength(2.0f) - )); + public static final Block TEST_BLOCK = blockWithSettingsOf(Material.WOOD, 2.0f); - public static final Block PALM_WOOD = WondersRegistry.registerBlock("palm_wood", new PillarBlock( - QuiltBlockSettings.copy(Blocks.OAK_WOOD).sounds(BlockSoundGroup.WOOD).strength(2.0f) - )); + // Palm wood and crew + public static final Block PALM_LOG = new PillarBlock(QuiltBlockSettings.copy(Blocks.OAK_LOG).sounds(BlockSoundGroup.WOOD).strength(2.0f)); + public static final Block PALM_WOOD = new PillarBlock(QuiltBlockSettings.copy(Blocks.OAK_WOOD).sounds(BlockSoundGroup.WOOD).strength(2.0f)); + public static final Block STRIPPED_PALM_LOG = new PillarBlock(QuiltBlockSettings.copy(Blocks.STRIPPED_OAK_LOG).sounds(BlockSoundGroup.WOOD).strength(2.0f)); + public static final Block STRIPPED_PALM_WOOD = new PillarBlock(QuiltBlockSettings.copy(Blocks.STRIPPED_OAK_WOOD).sounds(BlockSoundGroup.WOOD).strength(2.0f)); + public static final Block PALM_PLANKS = new Block(QuiltBlockSettings.copy(Blocks.OAK_PLANKS).sounds(BlockSoundGroup.WOOD).strength(2.0f)); + public static final StairsBlock PALM_STAIRS = new StairsBlock(Blocks.OAK_PLANKS.getDefaultState(), QuiltBlockSettings.copy(Blocks.OAK_STAIRS).sounds(BlockSoundGroup.WOOD).strength(2.0f)); + //TODO: add a Palm Fence Gate + public static final FenceBlock PALM_FENCE = new FenceBlock(QuiltBlockSettings.copy(Blocks.OAK_FENCE).sounds(BlockSoundGroup.WOOD).strength(2.0f)); + public static final SlabBlock PALM_SLAB = new SlabBlock(QuiltBlockSettings.copy(Blocks.OAK_SLAB).sounds(BlockSoundGroup.WOOD).strength(2.0f)); + public static final TrapdoorBlock PALM_TRAPDOOR = new TrapdoorBlock(QuiltBlockSettings.copy(Blocks.OAK_TRAPDOOR).sounds(BlockSoundGroup.WOOD).strength(2.0f)); - public static final Block STRIPPED_PALM_LOG = WondersRegistry.registerBlock("stripped_palm_log", new PillarBlock( - QuiltBlockSettings.copy(Blocks.STRIPPED_OAK_LOG).sounds(BlockSoundGroup.WOOD).strength(2.0f) - )); + static { + BLOCKS.put("test_block", TEST_BLOCK); + BLOCKS.put("palm_log", PALM_LOG); + BLOCKS.put("palm_wood", PALM_WOOD); + BLOCKS.put("stripped_palm_log", STRIPPED_PALM_LOG); + BLOCKS.put("stripped_palm_wood", STRIPPED_PALM_WOOD); + BLOCKS.put("palm_planks", PALM_PLANKS); + BLOCKS.put("palm_stairs", PALM_STAIRS); + BLOCKS.put("palm_fence", PALM_FENCE); + BLOCKS.put("palm_slab", PALM_SLAB); + BLOCKS.put("palm_trapdoor", PALM_TRAPDOOR); + } + //TODO: palm sign? + //public static final SignBlock PALM_SIGN = WondersRegistry.registerBlock("palm_sign", new SignBlock( + // Blocks.OAK_PLANKS.getDefaultState(), QuiltBlockSettings.copy(Blocks.OAK_SIGN).sounds(BlockSoundGroup.WOOD).strength(2.0f) + //)); - public static final Block STRIPPED_PALM_WOOD = WondersRegistry.registerBlock("stripped_palm_wood", new PillarBlock( - QuiltBlockSettings.copy(Blocks.STRIPPED_OAK_WOOD).sounds(BlockSoundGroup.WOOD).strength(2.0f) - )); + /** + * To be used for creating a block with just the settings of a {@code Material} + * @param material - the material to use for the block + * @param strength - float value of strength + * @see QuiltBlockSettings#of + * @see Material + */ + private static Block blockWithSettingsOf(Material material, Float strength){ + return new Block(QuiltBlockSettings.of(material).strength(strength)); + } - // Palm tree planks - public static final Block PALM_PLANKS = WondersRegistry.registerBlock("palm_planks", new Block( - QuiltBlockSettings.copy(Blocks.OAK_PLANKS).sounds(BlockSoundGroup.WOOD).strength(2.0f) - )); + public static void init(){ + //simple, innit? + BLOCKS.forEach((String name, Block block) -> Registry.register(Registry.BLOCK, Wonders.ID(name), block)); - public static final StairsBlock PALM_STAIRS = (StairsBlock) WondersRegistry.registerBlock("palm_stairs", new StairsBlock( - Blocks.OAK_PLANKS.getDefaultState(), QuiltBlockSettings.copy(Blocks.OAK_STAIRS).sounds(BlockSoundGroup.WOOD).strength(2.0f) - )); + //TODO this has got to go soon. Use Tags and REAs. + registerStrippableBlocks(); + registerFlammables(); + registerFuels(); + } - public static final FenceBlock PALM_FENCE = (FenceBlock) WondersRegistry.registerBlock("palm_fence", new FenceBlock( - QuiltBlockSettings.copy(Blocks.OAK_FENCE).sounds(BlockSoundGroup.WOOD).strength(2.0f) - )); + private static void registerStrippableBlocks(){ + StrippableBlockRegistry.register(PALM_LOG, STRIPPED_PALM_LOG); + StrippableBlockRegistry.register(PALM_WOOD, STRIPPED_PALM_WOOD); + } - public static final SlabBlock PALM_SLAB = (SlabBlock) WondersRegistry.registerBlock("palm_slab", new SlabBlock( - QuiltBlockSettings.copy(Blocks.OAK_SLAB).sounds(BlockSoundGroup.WOOD).strength(2.0f) - )); + private static void registerFuels() { + FuelRegistry registry = FuelRegistry.INSTANCE; - public static final TrapdoorBlock PALM_TRAPDOOR = (TrapdoorBlock) WondersRegistry.registerBlock("palm_trapdoor", new TrapdoorBlock( - QuiltBlockSettings.copy(Blocks.OAK_TRAPDOOR).sounds(BlockSoundGroup.WOOD).strength(2.0f) - )); + registry.add(PALM_LOG, 300); + registry.add(PALM_WOOD, 300); + registry.add(STRIPPED_PALM_LOG, 300); + registry.add(STRIPPED_PALM_WOOD, 300); + } - //public static final SignBlock PALM_SIGN = WondersRegistry.registerBlock("palm_sign", new SignBlock( - // Blocks.OAK_PLANKS.getDefaultState(), QuiltBlockSettings.copy(Blocks.OAK_SIGN).sounds(BlockSoundGroup.WOOD).strength(2.0f) - //)); + private static void registerFlammables() { + FlammableBlockRegistry flammableBocks = FlammableBlockRegistry.getDefaultInstance(); - private static Block createBlock(Material material, Float strength){ - return new Block(QuiltBlockSettings.of(material).strength(strength)); + flammableBocks.add(PALM_LOG, 5, 5); + flammableBocks.add(PALM_WOOD, 5, 5); + flammableBocks.add(STRIPPED_PALM_LOG, 5, 5); + flammableBocks.add(STRIPPED_PALM_WOOD, 5, 5); } - - public static void init(){} } diff --git a/src/main/java/io/github/debuggyteam/wonders/item/WondersItems.java b/src/main/java/io/github/debuggyteam/wonders/item/WondersItems.java index 40ddfbc..d6a8303 100644 --- a/src/main/java/io/github/debuggyteam/wonders/item/WondersItems.java +++ b/src/main/java/io/github/debuggyteam/wonders/item/WondersItems.java @@ -1,29 +1,26 @@ package io.github.debuggyteam.wonders.item; +import io.github.debuggyteam.wonders.Wonders; import io.github.debuggyteam.wonders.block.WondersBlocks; -import io.github.debuggyteam.wonders.util.WondersRegistry; +import net.minecraft.block.Block; +import net.minecraft.item.BlockItem; import net.minecraft.item.Item; +import net.minecraft.util.registry.Registry; public class WondersItems { // registering items - public static Item TEST = WondersRegistry.registerItem("test"); + public static Item TEST = new Item(new Item.Settings().group(Wonders.GROUP)); - // registering block items - public static Item TEST_BLOCK = WondersRegistry.registerBlockItem("test_block", WondersBlocks.TEST_BLOCK); + public static void init(){ + //dynamically register a new block item for every block. + WondersBlocks.BLOCKS.forEach((String name, Block block) -> register(new BlockItem(block, new Item.Settings().group(Wonders.GROUP)), name)); - // Palm logs - public static Item PALM_LOG = WondersRegistry.registerBlockItem("palm_log", WondersBlocks.PALM_LOG); - public static Item PALM_WOOD = WondersRegistry.registerBlockItem("palm_wood", WondersBlocks.PALM_WOOD); - public static Item STRIPPED_PALM_LOG = WondersRegistry.registerBlockItem("stripped_palm_log", WondersBlocks.STRIPPED_PALM_LOG); - public static Item STRIPPED_PALM_WOOD = WondersRegistry.registerBlockItem("stripped_palm_wood", WondersBlocks.STRIPPED_PALM_WOOD); + //regular Items + register(TEST, "test_item"); + } - // Palm planks - public static Item PALM_PLANKS = WondersRegistry.registerBlockItem("palm_planks", WondersBlocks.PALM_PLANKS); - public static Item PALM_STAIRS = WondersRegistry.registerBlockItem("palm_stairs", WondersBlocks.PALM_STAIRS); - public static Item PALM_FENCE = WondersRegistry.registerBlockItem("palm_fence", WondersBlocks.PALM_FENCE); - public static Item PALM_SLAB = WondersRegistry.registerBlockItem("palm_slab", WondersBlocks.PALM_SLAB); - public static Item PALM_TRAPDOOR = WondersRegistry.registerBlockItem("palm_trapdoor", WondersBlocks.PALM_TRAPDOOR); - - public static void init(){} + private static void register(T item, String name) { + Registry.register(Registry.ITEM, Wonders.ID(name), item); + } } diff --git a/src/main/java/io/github/debuggyteam/wonders/mixin/TitleScreenMixin.java b/src/main/java/io/github/debuggyteam/wonders/mixin/TitleScreenMixin.java deleted file mode 100644 index 098be20..0000000 --- a/src/main/java/io/github/debuggyteam/wonders/mixin/TitleScreenMixin.java +++ /dev/null @@ -1,16 +0,0 @@ -package io.github.debuggyteam.wonders.mixin; - -import io.github.debuggyteam.wonders.Wonders; -import net.minecraft.client.gui.screen.TitleScreen; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -@Mixin(TitleScreen.class) -public class TitleScreenMixin { - @Inject(method = "init", at = @At("TAIL")) - public void onInit(CallbackInfo ci) { - Wonders.LOGGER.info("This line is printed by an example mod mixin!"); - } -} diff --git a/src/main/java/io/github/debuggyteam/wonders/util/WondersRegistry.java b/src/main/java/io/github/debuggyteam/wonders/util/WondersRegistry.java deleted file mode 100644 index 5789779..0000000 --- a/src/main/java/io/github/debuggyteam/wonders/util/WondersRegistry.java +++ /dev/null @@ -1,22 +0,0 @@ -package io.github.debuggyteam.wonders.util; - -import io.github.debuggyteam.wonders.Wonders; -import net.minecraft.block.Block; -import net.minecraft.item.BlockItem; -import net.minecraft.item.Item; -import net.minecraft.item.ItemGroup; -import net.minecraft.util.registry.Registry; - -public class WondersRegistry { - public static Item registerItem(String itemName) { - return Registry.register(Registry.ITEM, Wonders.ID(itemName), new Item(new Item.Settings().group(Wonders.itemGroup))); - } - - public static Block registerBlock(String blockName, Block block){ - return Registry.register(Registry.BLOCK, Wonders.ID(blockName), block); - } - - public static Item registerBlockItem(String itemName, Block block) { - return Registry.register(Registry.ITEM, Wonders.ID(itemName), new BlockItem(block, new Item.Settings().group(Wonders.itemGroup))); - } -} diff --git a/src/main/java/io/github/debuggyteam/wonders/util/WondersUtils.java b/src/main/java/io/github/debuggyteam/wonders/util/WondersUtils.java index a398cbd..ddc234f 100644 --- a/src/main/java/io/github/debuggyteam/wonders/util/WondersUtils.java +++ b/src/main/java/io/github/debuggyteam/wonders/util/WondersUtils.java @@ -1,38 +1,7 @@ package io.github.debuggyteam.wonders.util; import io.github.debuggyteam.wonders.block.WondersBlocks; -import net.fabricmc.fabric.api.registry.FlammableBlockRegistry; -import net.fabricmc.fabric.api.registry.FuelRegistry; -import net.fabricmc.fabric.api.registry.StrippableBlockRegistry; public class WondersUtils { - public static void registerUtils() { - registerFuels(); - registerStrippableBlocks(); - registerFlammables(); - } - - private static void registerFuels() { - FuelRegistry registry = FuelRegistry.INSTANCE; - - registry.add(WondersBlocks.PALM_LOG, 300); - registry.add(WondersBlocks.PALM_WOOD, 300); - registry.add(WondersBlocks.STRIPPED_PALM_LOG, 300); - registry.add(WondersBlocks.STRIPPED_PALM_WOOD, 300); - } - - private static void registerStrippableBlocks(){ - StrippableBlockRegistry.register(WondersBlocks.PALM_LOG, WondersBlocks.STRIPPED_PALM_LOG); - StrippableBlockRegistry.register(WondersBlocks.PALM_WOOD, WondersBlocks.STRIPPED_PALM_WOOD); - } - - private static void registerFlammables() { - FlammableBlockRegistry flammableBocks = FlammableBlockRegistry.getDefaultInstance(); - - flammableBocks.add(WondersBlocks.PALM_LOG, 5, 5); - flammableBocks.add(WondersBlocks.PALM_WOOD, 5, 5); - flammableBocks.add(WondersBlocks.STRIPPED_PALM_LOG, 5, 5); - flammableBocks.add(WondersBlocks.STRIPPED_PALM_WOOD, 5, 5); - } } diff --git a/src/main/java/io/github/debuggyteam/wonders/world/biomes/WarmWondersBiomeCreator.java b/src/main/java/io/github/debuggyteam/wonders/world/biomes/WarmWondersBiomeCreator.java new file mode 100644 index 0000000..4a9d2db --- /dev/null +++ b/src/main/java/io/github/debuggyteam/wonders/world/biomes/WarmWondersBiomeCreator.java @@ -0,0 +1,42 @@ +package io.github.debuggyteam.wonders.world.biomes; + +import io.github.debuggyteam.wonders.world.gen.feature.WondersFeatures; +import net.minecraft.world.biome.Biome; +import net.minecraft.world.biome.BiomeEffects; +import net.minecraft.world.biome.GenerationSettings; +import net.minecraft.world.biome.SpawnSettings; +import net.minecraft.world.gen.GenerationStep; +import net.minecraft.world.gen.feature.DefaultBiomeFeatures; + +public class WarmWondersBiomeCreator { + public static Biome createBambooForest() { + GenerationSettings.Builder builder = new GenerationSettings.Builder() + //.feature(GenerationStep.Feature.RAW_GENERATION, WondersVegetationPlacedFeatures.) + .feature(GenerationStep.Feature.VEGETAL_DECORATION, WondersFeatures.LOTS_OF_BAMBOO); + SpawnSettings.Builder spawnBuilder = new SpawnSettings.Builder(); + DefaultBiomeFeatures.addJungleMobs(spawnBuilder); + DefaultBiomeFeatures.addMossyRocks(builder); + DefaultBiomeFeatures.addDefaultOres(builder); + DefaultBiomeFeatures.addAmethystGeodes(builder); + DefaultBiomeFeatures.addUndergroundVariety(builder); + return (new Biome.Builder() + .precipitation(Biome.Precipitation.RAIN) + .temperature(0.5f) + .temperatureModifier(Biome.TemperatureModifier.NONE) + .downfall(0.7f) + .effects( + (new BiomeEffects.Builder()) + .skyColor(0x79A6FF) + .fogColor(0x79A6FF) + .grassColor(0x79C05A) + .grassColorModifier(BiomeEffects.GrassColorModifier.NONE) + .foliageColor(0x59AE30) + .waterColor(0x3F76E4) + .waterFogColor(0x1E97F2) + .build()) + .generationSettings(builder.build()) + .spawnSettings(spawnBuilder.build()) + .build() + ); + } +} diff --git a/src/main/java/io/github/debuggyteam/wonders/world/biomes/WondersBiomes.java b/src/main/java/io/github/debuggyteam/wonders/world/biomes/WondersBiomes.java index dfb1010..d3b4c45 100644 --- a/src/main/java/io/github/debuggyteam/wonders/world/biomes/WondersBiomes.java +++ b/src/main/java/io/github/debuggyteam/wonders/world/biomes/WondersBiomes.java @@ -1,53 +1,21 @@ package io.github.debuggyteam.wonders.world.biomes; -import io.github.debuggyteam.wonders.world.gen.feature.WondersVegetationPlacedFeatures; -import io.github.debuggyteam.wonders.world.gen.feature.custom.CustomBoulder; +import io.github.debuggyteam.wonders.Wonders; import net.minecraft.util.registry.BuiltinRegistries; import net.minecraft.util.registry.Registry; -import net.minecraft.util.registry.RegistryKey; import net.minecraft.world.biome.*; -import net.minecraft.world.gen.GenerationStep; -import net.minecraft.world.gen.feature.DefaultBiomeFeatures; - -import static io.github.debuggyteam.wonders.Wonders.ID; public class WondersBiomes { - private static final RegistryKey BAMBOO_FOREST = RegistryKey.of(Registry.BIOME_KEY, ID("bamboo_forest")); + public static final Biome BAMBOO_FOREST = WarmWondersBiomeCreator.createBambooForest(); public static void registerWondersBiomes() { - Registry.register(BuiltinRegistries.BIOME, BAMBOO_FOREST.getValue(), createBambooForest()); + register(BAMBOO_FOREST, "bamboo_forest"); } - private static Biome createBambooForest() { - GenerationSettings.Builder builder = new GenerationSettings.Builder() - //.feature(GenerationStep.Feature.RAW_GENERATION, WondersVegetationPlacedFeatures.) - .feature(GenerationStep.Feature.VEGETAL_DECORATION, WondersVegetationPlacedFeatures.LOTS_OF_BAMBOO); - SpawnSettings.Builder spawnBuilder = new SpawnSettings.Builder(); - DefaultBiomeFeatures.addJungleMobs(spawnBuilder); - DefaultBiomeFeatures.addMossyRocks(builder); - DefaultBiomeFeatures.addDefaultOres(builder); - DefaultBiomeFeatures.addAmethystGeodes(builder); - DefaultBiomeFeatures.addUndergroundVariety(builder); - return (new Biome.Builder() - .precipitation(Biome.Precipitation.RAIN) - .temperature(0.5f) - .temperatureModifier(Biome.TemperatureModifier.NONE) - .downfall(0.7f) - .effects( - (new BiomeEffects.Builder()) - .skyColor(0x79A6FF) - .fogColor(0x79A6FF) - .grassColor(0x79C05A) - .grassColorModifier(BiomeEffects.GrassColorModifier.NONE) - .foliageColor(0x59AE30) - .waterColor(0x3F76E4) - .waterFogColor(0x1E97F2) - .build()) - .generationSettings(builder.build()) - .spawnSettings(spawnBuilder.build()) - .build() - ); - } + + private static void register(Biome biome, String name) { + Registry.register(BuiltinRegistries.BIOME, Wonders.ID(name), biome); + } public static void init(){} } diff --git a/src/main/java/io/github/debuggyteam/wonders/world/gen/feature/WondersVegetationPlacedFeatures.java b/src/main/java/io/github/debuggyteam/wonders/world/gen/feature/WondersFeatures.java similarity index 92% rename from src/main/java/io/github/debuggyteam/wonders/world/gen/feature/WondersVegetationPlacedFeatures.java rename to src/main/java/io/github/debuggyteam/wonders/world/gen/feature/WondersFeatures.java index dd092bc..0494755 100644 --- a/src/main/java/io/github/debuggyteam/wonders/world/gen/feature/WondersVegetationPlacedFeatures.java +++ b/src/main/java/io/github/debuggyteam/wonders/world/gen/feature/WondersFeatures.java @@ -12,7 +12,7 @@ /* Made by Joost */ -public class WondersVegetationPlacedFeatures extends VegetationPlacedFeatures { +public class WondersFeatures { public static final Holder LOTS_OF_BAMBOO; static { diff --git a/src/main/resources/wonders.mixins.json b/src/main/resources/wonders.mixins.json index 2fc9ae9..620d05d 100644 --- a/src/main/resources/wonders.mixins.json +++ b/src/main/resources/wonders.mixins.json @@ -5,7 +5,6 @@ "compatibilityLevel": "JAVA_17", "mixins": [], "client": [ - "TitleScreenMixin" ], "injectors": { "defaultRequire": 1 From 51edbb9fc115640fc0cc0522e88e603df3c451b0 Mon Sep 17 00:00:00 2001 From: peaceheis <69596656+peaceheis@users.noreply.github.com> Date: Thu, 28 Jul 2022 19:08:04 -0500 Subject: [PATCH 2/4] Codebase further cleaned up, but boulder generation very much broken --- .../github/debuggyteam/wonders/Wonders.java | 30 ++----- .../wonders/util/WondersUtils.java | 2 - .../world/biomes/WarmWondersBiomeCreator.java | 7 +- .../wonders/world/biomes/WondersBiomes.java | 7 +- .../wonders/world/gen/feature/OreBoulder.java | 78 +++++++++++++++++++ .../world/gen/feature/OreBoulderConfig.java | 49 ++++++++++++ .../feature/WondersConfiguredFeatures.java | 33 ++++++++ .../world/gen/feature/WondersFeatures.java | 29 +++---- .../gen/feature/WondersPlacedFeatures.java | 37 +++++++++ .../gen/feature/custom/CustomBoulder.java | 76 ------------------ 10 files changed, 219 insertions(+), 129 deletions(-) create mode 100644 src/main/java/io/github/debuggyteam/wonders/world/gen/feature/OreBoulder.java create mode 100644 src/main/java/io/github/debuggyteam/wonders/world/gen/feature/OreBoulderConfig.java create mode 100644 src/main/java/io/github/debuggyteam/wonders/world/gen/feature/WondersConfiguredFeatures.java create mode 100644 src/main/java/io/github/debuggyteam/wonders/world/gen/feature/WondersPlacedFeatures.java delete mode 100644 src/main/java/io/github/debuggyteam/wonders/world/gen/feature/custom/CustomBoulder.java diff --git a/src/main/java/io/github/debuggyteam/wonders/Wonders.java b/src/main/java/io/github/debuggyteam/wonders/Wonders.java index d6d0f74..68b1b93 100644 --- a/src/main/java/io/github/debuggyteam/wonders/Wonders.java +++ b/src/main/java/io/github/debuggyteam/wonders/Wonders.java @@ -2,19 +2,11 @@ import io.github.debuggyteam.wonders.block.WondersBlocks; import io.github.debuggyteam.wonders.item.WondersItems; -import io.github.debuggyteam.wonders.util.WondersUtils; import io.github.debuggyteam.wonders.world.biomes.WondersBiomes; -import io.github.debuggyteam.wonders.world.gen.feature.OreBoulder; -import net.minecraft.block.Blocks; +import io.github.debuggyteam.wonders.world.gen.feature.WondersFeatures; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; import net.minecraft.util.Identifier; -import net.minecraft.util.math.intprovider.ConstantIntProvider; -import net.minecraft.util.registry.Registry; -import net.minecraft.world.Heightmap; -import net.minecraft.world.gen.feature.ConfiguredFeature; -import net.minecraft.world.gen.feature.Feature; -import net.minecraft.world.gen.stateprovider.SimpleBlockStateProvider; import org.quiltmc.loader.api.ModContainer; import org.quiltmc.qsl.base.api.entrypoint.ModInitializer; import org.quiltmc.qsl.item.group.api.QuiltItemGroup; @@ -32,30 +24,18 @@ public class Wonders implements ModInitializer { Made by Joost */ private static final String MOD_ID = "wonders"; + public static final ItemGroup GROUP = QuiltItemGroup.builder(ID("itemgroup")).icon(() -> new ItemStack(WondersItems.TEST)).build(); + public static Identifier ID(String name) { return new Identifier(MOD_ID, name); } - public static final ItemGroup GROUP = QuiltItemGroup.builder(ID("itemgroup")).icon(() -> new ItemStack(WondersItems.TEST)).build(); - - private static final Feature BOULDER = new OreBoulder(OreBoulder.OreBoulderConfiguration.CODEC); - public static final ConfiguredFeature ROCK = BOULDER.configure(new OreBoulder.OreBoulderConfiguration(ConstantIntProvider.create(15), - new SimpleBlockStateProvider(Blocks.STONE.getDefaultState()))) - .decorate(Decorator.HEIGHTMAP.configure(new HeightmapDecoratorConfig(Heightmap.Type.OCEAN_FLOOR_WG))) - .spreadHorizontally() - .applyChance(5); - - - @Override public void onInitialize(ModContainer mod) { - - Registry.register(Registry.FEATURE, new Identifier("wonders", "rock"), ROCK); - WondersItems.init(); WondersBlocks.init(); - WondersBiomes.registerWondersBiomes(); + WondersItems.init(); - WondersUtils.registerUtils(); + WondersBiomes.init(); LOGGER.info("Everything loaded from: {}!", mod.metadata().name()); } diff --git a/src/main/java/io/github/debuggyteam/wonders/util/WondersUtils.java b/src/main/java/io/github/debuggyteam/wonders/util/WondersUtils.java index ddc234f..b3b1bf2 100644 --- a/src/main/java/io/github/debuggyteam/wonders/util/WondersUtils.java +++ b/src/main/java/io/github/debuggyteam/wonders/util/WondersUtils.java @@ -1,7 +1,5 @@ package io.github.debuggyteam.wonders.util; -import io.github.debuggyteam.wonders.block.WondersBlocks; - public class WondersUtils { } diff --git a/src/main/java/io/github/debuggyteam/wonders/world/biomes/WarmWondersBiomeCreator.java b/src/main/java/io/github/debuggyteam/wonders/world/biomes/WarmWondersBiomeCreator.java index 4a9d2db..d86ca83 100644 --- a/src/main/java/io/github/debuggyteam/wonders/world/biomes/WarmWondersBiomeCreator.java +++ b/src/main/java/io/github/debuggyteam/wonders/world/biomes/WarmWondersBiomeCreator.java @@ -1,6 +1,6 @@ package io.github.debuggyteam.wonders.world.biomes; -import io.github.debuggyteam.wonders.world.gen.feature.WondersFeatures; +import io.github.debuggyteam.wonders.world.gen.feature.WondersPlacedFeatures; import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.BiomeEffects; import net.minecraft.world.biome.GenerationSettings; @@ -9,10 +9,11 @@ import net.minecraft.world.gen.feature.DefaultBiomeFeatures; public class WarmWondersBiomeCreator { + public static Biome createBambooForest() { GenerationSettings.Builder builder = new GenerationSettings.Builder() - //.feature(GenerationStep.Feature.RAW_GENERATION, WondersVegetationPlacedFeatures.) - .feature(GenerationStep.Feature.VEGETAL_DECORATION, WondersFeatures.LOTS_OF_BAMBOO); + .feature(GenerationStep.Feature.RAW_GENERATION, WondersPlacedFeatures.COPPER_IRON_BOULDER) + .feature(GenerationStep.Feature.VEGETAL_DECORATION, WondersPlacedFeatures.LOTS_OF_BAMBOO); SpawnSettings.Builder spawnBuilder = new SpawnSettings.Builder(); DefaultBiomeFeatures.addJungleMobs(spawnBuilder); DefaultBiomeFeatures.addMossyRocks(builder); diff --git a/src/main/java/io/github/debuggyteam/wonders/world/biomes/WondersBiomes.java b/src/main/java/io/github/debuggyteam/wonders/world/biomes/WondersBiomes.java index d3b4c45..a1d9a12 100644 --- a/src/main/java/io/github/debuggyteam/wonders/world/biomes/WondersBiomes.java +++ b/src/main/java/io/github/debuggyteam/wonders/world/biomes/WondersBiomes.java @@ -3,19 +3,16 @@ import io.github.debuggyteam.wonders.Wonders; import net.minecraft.util.registry.BuiltinRegistries; import net.minecraft.util.registry.Registry; -import net.minecraft.world.biome.*; +import net.minecraft.world.biome.Biome; public class WondersBiomes { public static final Biome BAMBOO_FOREST = WarmWondersBiomeCreator.createBambooForest(); - public static void registerWondersBiomes() { + public static void init() { register(BAMBOO_FOREST, "bamboo_forest"); } - private static void register(Biome biome, String name) { Registry.register(BuiltinRegistries.BIOME, Wonders.ID(name), biome); } - - public static void init(){} } diff --git a/src/main/java/io/github/debuggyteam/wonders/world/gen/feature/OreBoulder.java b/src/main/java/io/github/debuggyteam/wonders/world/gen/feature/OreBoulder.java new file mode 100644 index 0000000..95d1c2f --- /dev/null +++ b/src/main/java/io/github/debuggyteam/wonders/world/gen/feature/OreBoulder.java @@ -0,0 +1,78 @@ +package io.github.debuggyteam.wonders.world.gen.feature; + +import com.mojang.serialization.Codec; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.MathHelper; +import net.minecraft.util.random.RandomGenerator; +import net.minecraft.world.StructureWorldAccess; +import net.minecraft.world.gen.feature.Feature; +import net.minecraft.world.gen.feature.util.FeatureContext; + +public class OreBoulder extends Feature { + public OreBoulder(Codec configCodec) { + super(configCodec); + } + + @Override + public boolean place(FeatureContext context) { + BlockPos position = context.getOrigin(); + RandomGenerator random = context.getRandom(); + OreBoulderConfig config = context.getConfig(); + + StructureWorldAccess worldGenWorldAccess = context.getWorld(); + + int eastRadius = config.eastRadius().get(random); + int westRadius = config.westRadius().get(random); + int northRadius = config.northRadius().get(random); + int southRadius = config.southRadius().get(random); + int topRadius = config.topRadius().get(random); + int bottomRadius = config.bottomRadius().get(random); + int blocksSubmerged = config.blocksSubmerged().get(random); + //since we're generating a bunch of mini features, we return the boolean AND of all of their results. + var val = + generateEighth(eastRadius, northRadius, topRadius, blocksSubmerged, true, true, true, position, context) && + generateEighth(eastRadius, northRadius, bottomRadius, blocksSubmerged, true, true, false, position, context) && + generateEighth(eastRadius, southRadius, topRadius, -blocksSubmerged, true, false, true, position, context) && + generateEighth(eastRadius, southRadius, bottomRadius, -blocksSubmerged, true, false, false, position, context) && + generateEighth(westRadius, northRadius, topRadius, blocksSubmerged, false, true, true, position, context) && + generateEighth(westRadius, northRadius, bottomRadius, blocksSubmerged, false, true, false, position, context) && + generateEighth(westRadius, southRadius, topRadius, -blocksSubmerged, false, false, true, position, context) && + generateEighth(westRadius, southRadius, bottomRadius, -blocksSubmerged, false, false, false, position, context); + + worldGenWorldAccess.setBlockState(context.getOrigin(), Blocks.BLUE_CONCRETE.getDefaultState(), 3); + return val; + } + + //generate the approriate section of the boulder + protected boolean generateEighth(int xRadius, int zRadius, int yRadius, int blocksSubmerged, boolean east, boolean north, boolean up, BlockPos origin, FeatureContext context) { + for(int y = blocksSubmerged; y < yRadius; y++) { // by adding the amount of blocks submerged, the y has less "time". + for(int x = 0; x < xRadius; x++) { + for(int z = 0; z < zRadius; z++) { + if(fallsInEllipsoid(x, y, z, xRadius, yRadius, zRadius)) { + StructureWorldAccess worldAccess = context.getWorld(); + RandomGenerator random = context.getRandom(); + BlockPos currentPos = origin.add( + east ? x : -x, + up ? y : -y, + north ? z : -z); + OreBoulderConfig config = context.getConfig(); + BlockState boulderBlock = config.boulderBlock().getBlockState(random, currentPos); + BlockState oreBlock = config.oreBlock().getBlockState(random, currentPos); + worldAccess.setBlockState(currentPos, random.nextFloat() < config.oreChance().get(random) ? oreBlock : boulderBlock, 3); //4 is what block piles usew, so let's go with that. + } + } + } + + } + return true; + } + + protected boolean fallsInEllipsoid(int x, int y, int z, int a, int b, int c) { + return ((MathHelper.square(x) / MathHelper.square(a)) + + (MathHelper.square(y) / MathHelper.square(b)) + + (MathHelper.square(z) / MathHelper.square(c))) <= 1; + } + +} diff --git a/src/main/java/io/github/debuggyteam/wonders/world/gen/feature/OreBoulderConfig.java b/src/main/java/io/github/debuggyteam/wonders/world/gen/feature/OreBoulderConfig.java new file mode 100644 index 0000000..384df86 --- /dev/null +++ b/src/main/java/io/github/debuggyteam/wonders/world/gen/feature/OreBoulderConfig.java @@ -0,0 +1,49 @@ +package io.github.debuggyteam.wonders.world.gen.feature; + +import com.mojang.serialization.Codec; +import com.mojang.serialization.codecs.RecordCodecBuilder; +import net.minecraft.util.math.floatprovider.FloatProvider; +import net.minecraft.util.math.intprovider.ConstantIntProvider; +import net.minecraft.util.math.intprovider.IntProvider; +import net.minecraft.world.gen.feature.FeatureConfig; +import net.minecraft.world.gen.stateprovider.BlockStateProvider; + +/** + * A (usually) assymetrical boulder config + * @param eastRadius - {@code IntProvider} for one side along the x-axis + * @param westRadius - {@code IntProvider} for the other side along x + * @param northRadius - {@code IntProvider} for one side along the z-axis + * @param southRadius - {@code IntProvider} for the other side along z + * @param topRadius - {@code IntProvider} for one side along the y-axis + * @param bottomRadius - {@code IntProvider} for the other side along y + * @param blocksSubmerged - {@code IntProvider} the amount of blocks that the boulder should be submerged into the ground. + * @param boulderBlock - {@code BlockStateProvider} the block to use for boulder. + * @param oreBlock - {@code BlockStateProvider} the block to use for ores. + * @param oreChance - {@code FloatProvider} for the chance of ores replacing the base boulder block. Should always be 1 or less. + * @see IntProvider + * @see BlockStateProvider + * @see FloatProvider + */ +public record OreBoulderConfig(IntProvider eastRadius, + IntProvider westRadius, + IntProvider northRadius, + IntProvider southRadius, + IntProvider topRadius, + IntProvider bottomRadius, + IntProvider blocksSubmerged, + BlockStateProvider boulderBlock, + BlockStateProvider oreBlock, + FloatProvider oreChance) implements FeatureConfig { + public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( + IntProvider.POSITIVE_CODEC.fieldOf("east_radius").forGetter(OreBoulderConfig::eastRadius), + IntProvider.POSITIVE_CODEC.fieldOf("west_radius").forGetter(OreBoulderConfig::westRadius), + IntProvider.POSITIVE_CODEC.fieldOf("north_radius").forGetter(OreBoulderConfig::northRadius), + IntProvider.POSITIVE_CODEC.fieldOf("south_radius").forGetter(OreBoulderConfig::southRadius), + IntProvider.POSITIVE_CODEC.fieldOf("top_radius").forGetter(OreBoulderConfig::topRadius), + IntProvider.POSITIVE_CODEC.fieldOf("bottom_radius").forGetter(OreBoulderConfig::bottomRadius), + IntProvider.POSITIVE_CODEC.fieldOf("blocksSubmerged").orElse(ConstantIntProvider.ZERO).forGetter(OreBoulderConfig::blocksSubmerged), + BlockStateProvider.TYPE_CODEC.fieldOf("boulder_block").forGetter(OreBoulderConfig::boulderBlock), + BlockStateProvider.TYPE_CODEC.fieldOf("ore_block").forGetter(OreBoulderConfig::oreBlock), + FloatProvider.VALUE_CODEC.fieldOf("ore_chance").forGetter(OreBoulderConfig::oreChance) + ).apply(instance, instance.stable(OreBoulderConfig::new))); +} diff --git a/src/main/java/io/github/debuggyteam/wonders/world/gen/feature/WondersConfiguredFeatures.java b/src/main/java/io/github/debuggyteam/wonders/world/gen/feature/WondersConfiguredFeatures.java new file mode 100644 index 0000000..66d3a17 --- /dev/null +++ b/src/main/java/io/github/debuggyteam/wonders/world/gen/feature/WondersConfiguredFeatures.java @@ -0,0 +1,33 @@ +package io.github.debuggyteam.wonders.world.gen.feature; + +import io.github.debuggyteam.wonders.Wonders; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; +import net.minecraft.util.Holder; +import net.minecraft.util.collection.DataPool; +import net.minecraft.util.math.floatprovider.FloatProvider; +import net.minecraft.util.math.floatprovider.UniformFloatProvider; +import net.minecraft.util.math.intprovider.UniformIntProvider; +import net.minecraft.util.registry.BuiltinRegistries; +import net.minecraft.world.gen.feature.ConfiguredFeature; +import net.minecraft.world.gen.stateprovider.SimpleBlockStateProvider; +import net.minecraft.world.gen.stateprovider.WeightedBlockStateProvider; + +public class WondersConfiguredFeatures { + private static final ConfiguredFeature _COPPER_IRON_BOULDER = new ConfiguredFeature<>(WondersFeatures.ORE_BOULDER, + new OreBoulderConfig(UniformIntProvider.create(2, 5), UniformIntProvider.create(2, 5), UniformIntProvider.create(2, 5), UniformIntProvider.create(2, 5), UniformIntProvider.create(3, 5), UniformIntProvider.create(3, 5), UniformIntProvider.create(1, 3), SimpleBlockStateProvider.of(Blocks.MOSSY_COBBLESTONE.getDefaultState()), new WeightedBlockStateProvider(DataPool.builder().add(Blocks.COPPER_ORE.getDefaultState(), 1).add(Blocks.IRON_ORE.getDefaultState(), 2).build()), UniformFloatProvider.create(0.04F, 0.041F))); + /** Stone Boulder w/ 2.5% chance / block of having Iron Ore, and 1.5% chance of having Copper Ore. */ + public static final Holder> COPPER_IRON_BOULDER; + + static { + WondersFeatures.init(); + COPPER_IRON_BOULDER = register(_COPPER_IRON_BOULDER, "copper_iron_boulder"); + } + public static void init() { + + } + + private static Holder> register(ConfiguredFeature feature, String name) { + return BuiltinRegistries.register(BuiltinRegistries.CONFIGURED_FEATURE, Wonders.ID(name), feature); + } +} diff --git a/src/main/java/io/github/debuggyteam/wonders/world/gen/feature/WondersFeatures.java b/src/main/java/io/github/debuggyteam/wonders/world/gen/feature/WondersFeatures.java index 0494755..2dca2d4 100644 --- a/src/main/java/io/github/debuggyteam/wonders/world/gen/feature/WondersFeatures.java +++ b/src/main/java/io/github/debuggyteam/wonders/world/gen/feature/WondersFeatures.java @@ -1,27 +1,20 @@ package io.github.debuggyteam.wonders.world.gen.feature; -import net.minecraft.util.Holder; -import net.minecraft.world.gen.decorator.BiomePlacementModifier; -import net.minecraft.world.gen.decorator.InSquarePlacementModifier; -import net.minecraft.world.gen.decorator.NoiseBasedCountPlacementModifier; -import net.minecraft.world.gen.feature.PlacedFeature; -import net.minecraft.world.gen.feature.VegetationConfiguredFeatures; -import net.minecraft.world.gen.feature.VegetationPlacedFeatures; -import net.minecraft.world.gen.feature.util.PlacedFeatureUtil; +import io.github.debuggyteam.wonders.Wonders; +import net.minecraft.util.registry.Registry; +import net.minecraft.world.gen.feature.Feature; +import net.minecraft.world.gen.feature.FeatureConfig; /* Made by Joost */ public class WondersFeatures { - public static final Holder LOTS_OF_BAMBOO; + public static Feature ORE_BOULDER = new OreBoulder<>(OreBoulderConfig.CODEC); - static { - LOTS_OF_BAMBOO = PlacedFeatureUtil.register( - "lots_of_bamboo", - VegetationConfiguredFeatures.BAMBOO_SOME_PODZOL, - NoiseBasedCountPlacementModifier.create(115, 75.5, 0.73), - InSquarePlacementModifier.getInstance(), - PlacedFeatureUtil.WORLD_SURFACE_WG_HEIGHTMAP, - BiomePlacementModifier.getInstance()); - } + public static void init() { + register(ORE_BOULDER, "ore_boulder"); + } + private static void register(Feature feature, String name) { + Registry.register(Registry.FEATURE, Wonders.ID(name), feature); + } } diff --git a/src/main/java/io/github/debuggyteam/wonders/world/gen/feature/WondersPlacedFeatures.java b/src/main/java/io/github/debuggyteam/wonders/world/gen/feature/WondersPlacedFeatures.java new file mode 100644 index 0000000..9597add --- /dev/null +++ b/src/main/java/io/github/debuggyteam/wonders/world/gen/feature/WondersPlacedFeatures.java @@ -0,0 +1,37 @@ +package io.github.debuggyteam.wonders.world.gen.feature; + +import io.github.debuggyteam.wonders.Wonders; +import net.minecraft.util.Holder; +import net.minecraft.util.registry.BuiltinRegistries; +import net.minecraft.world.gen.decorator.BiomePlacementModifier; +import net.minecraft.world.gen.decorator.InSquarePlacementModifier; +import net.minecraft.world.gen.decorator.NoiseBasedCountPlacementModifier; +import net.minecraft.world.gen.feature.ConfiguredFeature; +import net.minecraft.world.gen.feature.PlacedFeature; +import net.minecraft.world.gen.feature.PlacementModifier; +import net.minecraft.world.gen.feature.VegetationConfiguredFeatures; +import net.minecraft.world.gen.feature.util.PlacedFeatureUtil; + +import java.util.List; + +public class WondersPlacedFeatures { + private static final PlacedFeature _LOTS_OF_BAMBOO = placedFeature(VegetationConfiguredFeatures.BAMBOO_SOME_PODZOL, NoiseBasedCountPlacementModifier.create(115, 75.5, 0.73), InSquarePlacementModifier.getInstance(), PlacedFeatureUtil.WORLD_SURFACE_WG_HEIGHTMAP, BiomePlacementModifier.getInstance()); + public static final Holder LOTS_OF_BAMBOO; + private static final PlacedFeature _COPPER_IRON_BOULDER = placedFeature(WondersConfiguredFeatures.COPPER_IRON_BOULDER, InSquarePlacementModifier.getInstance(), PlacedFeatureUtil.OCEAN_FLOOR_HEIGHTMAP); + /** @see io.github.debuggyteam.wonders.world.gen.feature.WondersConfiguredFeatures#COPPER_IRON_BOULDER */ + public static final Holder COPPER_IRON_BOULDER; + + static { + WondersConfiguredFeatures.init(); + LOTS_OF_BAMBOO = register(_LOTS_OF_BAMBOO, "lots_of_bamboo"); + COPPER_IRON_BOULDER = register(_COPPER_IRON_BOULDER, "copper_iron_boulder"); + } + + private static PlacedFeature placedFeature(Holder> configuredFeature, PlacementModifier... modifiers) { + return new PlacedFeature(Holder.upcast(configuredFeature), List.of(modifiers)); + } + + private static Holder register(PlacedFeature feature, String name) { + return BuiltinRegistries.register(BuiltinRegistries.PLACED_FEATURE, Wonders.ID(name), feature); + } +} diff --git a/src/main/java/io/github/debuggyteam/wonders/world/gen/feature/custom/CustomBoulder.java b/src/main/java/io/github/debuggyteam/wonders/world/gen/feature/custom/CustomBoulder.java deleted file mode 100644 index eb90a91..0000000 --- a/src/main/java/io/github/debuggyteam/wonders/world/gen/feature/custom/CustomBoulder.java +++ /dev/null @@ -1,76 +0,0 @@ -package io.github.debuggyteam.wonders.world.gen.feature.custom; - -import com.mojang.serialization.Codec; -import com.mojang.serialization.codecs.RecordCodecBuilder; -import net.minecraft.block.BlockState; -import net.minecraft.util.Rarity; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.intprovider.IntProvider; -import net.minecraft.util.random.RandomGenerator; -import net.minecraft.world.StructureWorldAccess; -import net.minecraft.world.gen.decorator.PlacementModifierType; -import net.minecraft.world.gen.decorator.RarityFilterPlacementModifier; -import net.minecraft.world.gen.feature.*; -import net.minecraft.world.gen.feature.util.FeatureContext; -import net.minecraft.world.gen.stateprovider.BlockStateProvider; - -public class CustomBoulder extends Feature { - /* - create a boulder that has a varying shape, optionally; have the boulder contain ores - iron: 2.5% chance, copper: 1.5% chance - - this could be expanded to have an outer shell, and an inner shell with ores thrown in - could be used as a meteor(ite) too - */ - public record BoulderConfig(IntProvider baseSize, BlockStateProvider interiorBlock) implements FeatureConfig { - public static final Codec CODEC = RecordCodecBuilder.create(instance -> instance.group( - IntProvider.VALUE_CODEC.fieldOf("base_size").forGetter(BoulderConfig::baseSize), - //IntProvider.VALUE_CODEC.fieldOf("size_variation").forGetter(BoulderConfig::sizeVariation), - BlockStateProvider.TYPE_CODEC.fieldOf("interior_block").forGetter(BoulderConfig::interiorBlock) - //BlockStateProvider.TYPE_CODEC.fieldOf("exterior_block").forGetter(BoulderConfig::exteriorBlock) - ).apply(instance, instance.stable(BoulderConfig::new))); - } - - public CustomBoulder(Codec configCodec) { - super(configCodec); - } - - @Override - public boolean place(FeatureContext context) { - BlockPos position = context.getOrigin(); - StructureWorldAccess worldGenWorldAccess = context.getWorld(); - RandomGenerator random = context.getRandom(); - - BoulderConfig config; - for(config = context.getConfig(); position.getY() > worldGenWorldAccess.getBottomY() + 3; position = position.down()) { - if (!worldGenWorldAccess.isAir(position.down())) { - BlockState blockState = worldGenWorldAccess.getBlockState(position.down()); - if (isSoil(blockState) || isStone(blockState)) { - break; - } - } - } - - if (position.getY() <= worldGenWorldAccess.getBottomY() + 5) { - return false; - } else { - for(int i = 0; i < config.baseSize.get(random); i++) { - int j = random.nextInt(3); - int k = random.nextInt(5); - int l = random.nextInt(4); - - float rockShape = (float)(j + k + l) * 0.4f + 0.5f; - - for (BlockPos position2 : BlockPos.iterate(position.add(-j, -k, -l), position.add(j, k, l))) { - if (position2.getSquaredDistance(position) <= (double)(rockShape * rockShape)) { - worldGenWorldAccess.setBlockState(position2, config.interiorBlock().getBlockState(context.getRandom(), position), 4); - } - } - - position = position.add(-1 + random.nextInt(3), -random.nextInt(5), -1 + random.nextInt(4)); - } - } - - return true; - } -} From 088622348abde9940dfe4fd475b079b312eac23c Mon Sep 17 00:00:00 2001 From: JoostMSoftware Date: Mon, 1 Aug 2022 01:16:47 +0200 Subject: [PATCH 3/4] bumped version to the latest versions --- build.gradle | 1 + gradle.properties | 2 +- gradle/libs.versions.toml | 10 ++++++---- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/build.gradle b/build.gradle index faf55ff..44a24a0 100644 --- a/build.gradle +++ b/build.gradle @@ -30,6 +30,7 @@ dependencies { // QSL is not a complete API; You will need Quilted Fabric API to fill in the gaps. // Quilted Fabric API will automatically pull in the correct QSL version. + modImplementation libs.qsl modImplementation libs.quilted.fabric.api // modImplementation libs.bundles.quilted.fabric.api // If you wish to use Fabric API's deprecated modules, you can replace the above line with this one } diff --git a/gradle.properties b/gradle.properties index e53d8a4..1006944 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,7 @@ org.gradle.jvmargs = -Xmx1G org.gradle.parallel = true # Mod Properties -version = 1.0.0+1.19 +version = 1.0.0+1.19.1 maven_group = io.github.debuggyteam archives_base_name = wonders diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 6f1b263..8f7e434 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,10 +1,11 @@ [versions] # The latest versions are available at https://lambdaurora.dev/tools/import_quilt.html -minecraft = "1.19" -quilt_mappings = "1.19+build.1" -quilt_loader = "0.17.1-beta.6" +minecraft = "1.19.1" +quilt_mappings = "1.19.1+build.2" +quilt_loader = "0.17.2-beta.2" -quilted_fabric_api = "2.0.0-beta.8+0.57.0-1.19" +qsl = "3.0.0-beta.3+1.19.1" +quilted_fabric_api = "4.0.0-beta.1+0.58.5-1.19.1" [libraries] minecraft = { module = "com.mojang:minecraft", version.ref = "minecraft" } @@ -13,6 +14,7 @@ quilt_loader = { module = "org.quiltmc:quilt-loader", version.ref = "quilt_loade quilted_fabric_api = { module = "org.quiltmc.quilted-fabric-api:quilted-fabric-api", version.ref = "quilted_fabric_api" } quilted_fabric_api_deprecated = { module = "org.quiltmc.quilted-fabric-api:quilted-fabric-api-deprecated", version.ref = "quilted_fabric_api" } +qsl = { module = "org.quiltmc:qsl", version.ref = "qsl"} # If you have multiple similar dependencies, you can declare a dependency bundle and reference it on the build script with "libs.bundles.example". [bundles] From 7b24f1e534ad3160ca12469be69b14bd9225578a Mon Sep 17 00:00:00 2001 From: peaceheis <69596656+peaceheis@users.noreply.github.com> Date: Mon, 5 Sep 2022 15:59:22 -0400 Subject: [PATCH 4/4] Don't use currently broken boulders, Add mossy rocks --- .../world/biomes/WarmWondersBiomeCreator.java | 2 +- .../wonders/world/gen/feature/OreBoulder.java | 27 +++++++++---------- .../feature/WondersConfiguredFeatures.java | 2 +- .../gen/feature/WondersPlacedFeatures.java | 5 ++-- .../resources/assets/wonders/lang/en_us.json | 3 ++- 5 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/main/java/io/github/debuggyteam/wonders/world/biomes/WarmWondersBiomeCreator.java b/src/main/java/io/github/debuggyteam/wonders/world/biomes/WarmWondersBiomeCreator.java index d86ca83..eaa8dbe 100644 --- a/src/main/java/io/github/debuggyteam/wonders/world/biomes/WarmWondersBiomeCreator.java +++ b/src/main/java/io/github/debuggyteam/wonders/world/biomes/WarmWondersBiomeCreator.java @@ -12,7 +12,7 @@ public class WarmWondersBiomeCreator { public static Biome createBambooForest() { GenerationSettings.Builder builder = new GenerationSettings.Builder() - .feature(GenerationStep.Feature.RAW_GENERATION, WondersPlacedFeatures.COPPER_IRON_BOULDER) + //.feature(GenerationStep.Feature.LOCAL_MODIFICATIONS, WondersPlacedFeatures.COPPER_IRON_BOULDER) .feature(GenerationStep.Feature.VEGETAL_DECORATION, WondersPlacedFeatures.LOTS_OF_BAMBOO); SpawnSettings.Builder spawnBuilder = new SpawnSettings.Builder(); DefaultBiomeFeatures.addJungleMobs(spawnBuilder); diff --git a/src/main/java/io/github/debuggyteam/wonders/world/gen/feature/OreBoulder.java b/src/main/java/io/github/debuggyteam/wonders/world/gen/feature/OreBoulder.java index 95d1c2f..8d55fa9 100644 --- a/src/main/java/io/github/debuggyteam/wonders/world/gen/feature/OreBoulder.java +++ b/src/main/java/io/github/debuggyteam/wonders/world/gen/feature/OreBoulder.java @@ -32,20 +32,20 @@ public boolean place(FeatureContext context) { int blocksSubmerged = config.blocksSubmerged().get(random); //since we're generating a bunch of mini features, we return the boolean AND of all of their results. var val = - generateEighth(eastRadius, northRadius, topRadius, blocksSubmerged, true, true, true, position, context) && - generateEighth(eastRadius, northRadius, bottomRadius, blocksSubmerged, true, true, false, position, context) && - generateEighth(eastRadius, southRadius, topRadius, -blocksSubmerged, true, false, true, position, context) && - generateEighth(eastRadius, southRadius, bottomRadius, -blocksSubmerged, true, false, false, position, context) && - generateEighth(westRadius, northRadius, topRadius, blocksSubmerged, false, true, true, position, context) && - generateEighth(westRadius, northRadius, bottomRadius, blocksSubmerged, false, true, false, position, context) && - generateEighth(westRadius, southRadius, topRadius, -blocksSubmerged, false, false, true, position, context) && - generateEighth(westRadius, southRadius, bottomRadius, -blocksSubmerged, false, false, false, position, context); + generateEighth(eastRadius, northRadius, topRadius, 0, true, true, true, position, context) && + generateEighth(eastRadius, northRadius, bottomRadius, -0, true, true, false, position, context) && + generateEighth(eastRadius, southRadius, topRadius, 0, true, false, true, position, context) && + generateEighth(eastRadius, southRadius, bottomRadius, -0, true, false, false, position, context) && + generateEighth(westRadius, northRadius, topRadius, 0, false, true, true, position, context) && + generateEighth(westRadius, northRadius, bottomRadius, -0, false, true, false, position, context) && + generateEighth(westRadius, southRadius, topRadius, 0, false, false, true, position, context) && + generateEighth(westRadius, southRadius, bottomRadius, -0, false, false, false, position, context); worldGenWorldAccess.setBlockState(context.getOrigin(), Blocks.BLUE_CONCRETE.getDefaultState(), 3); return val; } - //generate the approriate section of the boulder + //generate the appropriate section of the boulder protected boolean generateEighth(int xRadius, int zRadius, int yRadius, int blocksSubmerged, boolean east, boolean north, boolean up, BlockPos origin, FeatureContext context) { for(int y = blocksSubmerged; y < yRadius; y++) { // by adding the amount of blocks submerged, the y has less "time". for(int x = 0; x < xRadius; x++) { @@ -64,15 +64,14 @@ protected boolean generateEighth(int xRadius, int zRadius, int yRadius, int bloc } } } - } return true; } - protected boolean fallsInEllipsoid(int x, int y, int z, int a, int b, int c) { - return ((MathHelper.square(x) / MathHelper.square(a)) + - (MathHelper.square(y) / MathHelper.square(b)) + - (MathHelper.square(z) / MathHelper.square(c))) <= 1; + protected boolean fallsInEllipsoid(float x, float y, float z, float a, float b, float c) { + return ((MathHelper.square(x/a)) + + (MathHelper.square(y/b)) + + (MathHelper.square(z/c))) <= 1; } } diff --git a/src/main/java/io/github/debuggyteam/wonders/world/gen/feature/WondersConfiguredFeatures.java b/src/main/java/io/github/debuggyteam/wonders/world/gen/feature/WondersConfiguredFeatures.java index 66d3a17..9b7d168 100644 --- a/src/main/java/io/github/debuggyteam/wonders/world/gen/feature/WondersConfiguredFeatures.java +++ b/src/main/java/io/github/debuggyteam/wonders/world/gen/feature/WondersConfiguredFeatures.java @@ -15,7 +15,7 @@ public class WondersConfiguredFeatures { private static final ConfiguredFeature _COPPER_IRON_BOULDER = new ConfiguredFeature<>(WondersFeatures.ORE_BOULDER, - new OreBoulderConfig(UniformIntProvider.create(2, 5), UniformIntProvider.create(2, 5), UniformIntProvider.create(2, 5), UniformIntProvider.create(2, 5), UniformIntProvider.create(3, 5), UniformIntProvider.create(3, 5), UniformIntProvider.create(1, 3), SimpleBlockStateProvider.of(Blocks.MOSSY_COBBLESTONE.getDefaultState()), new WeightedBlockStateProvider(DataPool.builder().add(Blocks.COPPER_ORE.getDefaultState(), 1).add(Blocks.IRON_ORE.getDefaultState(), 2).build()), UniformFloatProvider.create(0.04F, 0.041F))); + new OreBoulderConfig(UniformIntProvider.create(1, 3), UniformIntProvider.create(1, 3), UniformIntProvider.create(1, 3), UniformIntProvider.create(1, 3), UniformIntProvider.create(2, 3), UniformIntProvider.create(2, 3), UniformIntProvider.create(1, 3), SimpleBlockStateProvider.of(Blocks.MOSSY_COBBLESTONE.getDefaultState()), new WeightedBlockStateProvider(DataPool.builder().add(Blocks.COPPER_ORE.getDefaultState(), 1).add(Blocks.IRON_ORE.getDefaultState(), 2).build()), UniformFloatProvider.create(0.04F, 0.041F))); /** Stone Boulder w/ 2.5% chance / block of having Iron Ore, and 1.5% chance of having Copper Ore. */ public static final Holder> COPPER_IRON_BOULDER; diff --git a/src/main/java/io/github/debuggyteam/wonders/world/gen/feature/WondersPlacedFeatures.java b/src/main/java/io/github/debuggyteam/wonders/world/gen/feature/WondersPlacedFeatures.java index 9597add..c0298c7 100644 --- a/src/main/java/io/github/debuggyteam/wonders/world/gen/feature/WondersPlacedFeatures.java +++ b/src/main/java/io/github/debuggyteam/wonders/world/gen/feature/WondersPlacedFeatures.java @@ -6,6 +6,7 @@ import net.minecraft.world.gen.decorator.BiomePlacementModifier; import net.minecraft.world.gen.decorator.InSquarePlacementModifier; import net.minecraft.world.gen.decorator.NoiseBasedCountPlacementModifier; +import net.minecraft.world.gen.decorator.RarityFilterPlacementModifier; import net.minecraft.world.gen.feature.ConfiguredFeature; import net.minecraft.world.gen.feature.PlacedFeature; import net.minecraft.world.gen.feature.PlacementModifier; @@ -15,9 +16,9 @@ import java.util.List; public class WondersPlacedFeatures { - private static final PlacedFeature _LOTS_OF_BAMBOO = placedFeature(VegetationConfiguredFeatures.BAMBOO_SOME_PODZOL, NoiseBasedCountPlacementModifier.create(115, 75.5, 0.73), InSquarePlacementModifier.getInstance(), PlacedFeatureUtil.WORLD_SURFACE_WG_HEIGHTMAP, BiomePlacementModifier.getInstance()); + private static final PlacedFeature _LOTS_OF_BAMBOO = placedFeature(VegetationConfiguredFeatures.BAMBOO_SOME_PODZOL,NoiseBasedCountPlacementModifier.create(115, 75.5, 0.73), InSquarePlacementModifier.getInstance(), PlacedFeatureUtil.WORLD_SURFACE_WG_HEIGHTMAP, BiomePlacementModifier.getInstance()); public static final Holder LOTS_OF_BAMBOO; - private static final PlacedFeature _COPPER_IRON_BOULDER = placedFeature(WondersConfiguredFeatures.COPPER_IRON_BOULDER, InSquarePlacementModifier.getInstance(), PlacedFeatureUtil.OCEAN_FLOOR_HEIGHTMAP); + private static final PlacedFeature _COPPER_IRON_BOULDER = placedFeature(WondersConfiguredFeatures.COPPER_IRON_BOULDER, RarityFilterPlacementModifier.create(10), InSquarePlacementModifier.getInstance(), PlacedFeatureUtil.WORLD_SURFACE_WG_HEIGHTMAP); /** @see io.github.debuggyteam.wonders.world.gen.feature.WondersConfiguredFeatures#COPPER_IRON_BOULDER */ public static final Holder COPPER_IRON_BOULDER; diff --git a/src/main/resources/assets/wonders/lang/en_us.json b/src/main/resources/assets/wonders/lang/en_us.json index b9e1270..e7665e2 100644 --- a/src/main/resources/assets/wonders/lang/en_us.json +++ b/src/main/resources/assets/wonders/lang/en_us.json @@ -5,5 +5,6 @@ "block.wonders.palm_log": "Palm Log", "block.wonders.palm_wood": "Palm Wood", "block.wonders.stripped_palm_log": "Stripped Palm Log", - "block.wonders.stripped_palm_wood": "Stripped Palm Wood" + "block.wonders.stripped_palm_wood": "Stripped Palm Wood", + "biome.wonders.bamboo_forest": "Wonders: Bamboo Forest" }