preliminary worldgen and refactor packages

This commit is contained in:
nelle 2024-12-21 13:49:22 -07:00
parent e7d056a214
commit d5ef637aa7
18 changed files with 173 additions and 89 deletions

View file

@ -0,0 +1,33 @@
package observer.nelle.roses;
import net.fabricmc.fabric.api.datagen.v1.DataGeneratorEntrypoint;
import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator;
import net.minecraft.registry.RegistryBuilder;
import net.minecraft.registry.RegistryKeys;
import observer.nelle.roses.datagen.RosesBlockTagProvider;
import observer.nelle.roses.datagen.RosesLootTableProvider;
import observer.nelle.roses.datagen.RosesRecipeProvider;
import observer.nelle.roses.datagen.RosesRegistryGenerator;
import observer.nelle.roses.world.RosesConfiguredFeatures;
import observer.nelle.roses.world.RosesPlacedFeatures;
public class RosesDataGenerator implements DataGeneratorEntrypoint {
@Override
public void onInitializeDataGenerator(FabricDataGenerator generator) {
FabricDataGenerator.Pack pack = generator.createPack();
// Adding a provider example:
//
pack.addProvider(RosesRecipeProvider::new);
pack.addProvider(RosesBlockTagProvider::new);
pack.addProvider(RosesLootTableProvider::new);
pack.addProvider(RosesRegistryGenerator::new);
}
@Override
public void buildRegistry(RegistryBuilder registryBuilder) {
registryBuilder.addRegistry(RegistryKeys.CONFIGURED_FEATURE, RosesConfiguredFeatures::bootstrap);
registryBuilder.addRegistry(RegistryKeys.PLACED_FEATURE, RosesPlacedFeatures::bootstrap);
}
}

View file

@ -1,10 +1,10 @@
package observer.nelle.roses_mod.datagen; package observer.nelle.roses.datagen;
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider; import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider;
import net.minecraft.registry.RegistryWrapper; import net.minecraft.registry.RegistryWrapper;
import net.minecraft.registry.tag.BlockTags; import net.minecraft.registry.tag.BlockTags;
import observer.nelle.roses_mod.RosesBlocks; import observer.nelle.roses.RosesBlocks;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;

View file

@ -1,4 +1,4 @@
package observer.nelle.roses_mod.datagen; package observer.nelle.roses.datagen;
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricBlockLootTableProvider; import net.fabricmc.fabric.api.datagen.v1.provider.FabricBlockLootTableProvider;
@ -12,13 +12,13 @@ import net.minecraft.loot.function.ApplyBonusLootFunction;
import net.minecraft.loot.function.SetCountLootFunction; import net.minecraft.loot.function.SetCountLootFunction;
import net.minecraft.loot.provider.number.UniformLootNumberProvider; import net.minecraft.loot.provider.number.UniformLootNumberProvider;
import net.minecraft.registry.RegistryWrapper; import net.minecraft.registry.RegistryWrapper;
import observer.nelle.roses_mod.RosesBlocks; import observer.nelle.roses.RosesBlocks;
import java.util.Objects; import java.util.Objects;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
public class RosesLootTableProvider extends FabricBlockLootTableProvider { public class RosesLootTableProvider extends FabricBlockLootTableProvider {
protected RosesLootTableProvider(FabricDataOutput dataOutput, CompletableFuture<RegistryWrapper.WrapperLookup> registryLookup) { public RosesLootTableProvider(FabricDataOutput dataOutput, CompletableFuture<RegistryWrapper.WrapperLookup> registryLookup) {
super(dataOutput, registryLookup); super(dataOutput, registryLookup);
} }

View file

@ -1,4 +1,4 @@
package observer.nelle.roses_mod.datagen; package observer.nelle.roses.datagen;
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricRecipeProvider; import net.fabricmc.fabric.api.datagen.v1.provider.FabricRecipeProvider;
@ -6,7 +6,7 @@ import net.minecraft.data.server.recipe.RecipeExporter;
import net.minecraft.item.Items; import net.minecraft.item.Items;
import net.minecraft.recipe.book.RecipeCategory; import net.minecraft.recipe.book.RecipeCategory;
import net.minecraft.registry.RegistryWrapper; import net.minecraft.registry.RegistryWrapper;
import observer.nelle.roses_mod.RosesBlocks; import observer.nelle.roses.RosesBlocks;
import java.util.Objects; import java.util.Objects;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;

View file

@ -0,0 +1,25 @@
package observer.nelle.roses.datagen;
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricDynamicRegistryProvider;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.registry.RegistryWrapper;
import java.util.concurrent.CompletableFuture;
public class RosesRegistryGenerator extends FabricDynamicRegistryProvider {
public RosesRegistryGenerator(FabricDataOutput output, CompletableFuture<RegistryWrapper.WrapperLookup> registriesFuture) {
super(output, registriesFuture);
}
@Override
protected void configure(RegistryWrapper.WrapperLookup registries, Entries entries) {
entries.addAll(registries.getWrapperOrThrow(RegistryKeys.CONFIGURED_FEATURE));
entries.addAll(registries.getWrapperOrThrow(RegistryKeys.PLACED_FEATURE));
}
@Override
public String getName() {
return "";
}
}

View file

@ -0,0 +1,28 @@
package observer.nelle.roses.world;
// Configured Feature (flowers, how does this look like) -> Placed Feature (How is this feature placed) -> WorldGen/BiomeMod (Where is our feature placed)
import net.minecraft.registry.Registerable;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.util.Identifier;
import net.minecraft.world.gen.feature.ConfiguredFeature;
import net.minecraft.world.gen.feature.Feature;
import net.minecraft.world.gen.feature.FeatureConfig;
import observer.nelle.roses.RosesModKt;
public class RosesConfiguredFeatures {
public static void bootstrap(Registerable<ConfiguredFeature<?, ?>> context) {
}
public static RegistryKey<ConfiguredFeature<?, ?>> registerKey(String name) {
return RegistryKey.of(RegistryKeys.CONFIGURED_FEATURE, Identifier.of(RosesModKt.MOD_ID, name));
}
private static <FC extends FeatureConfig, F extends Feature<FC>> void register(Registerable<ConfiguredFeature<?, ?>> context,
RegistryKey<ConfiguredFeature<?, ?>> key, F feature, FC configuration) {
context.register(key, new ConfiguredFeature<>(feature, configuration));
}
}

View file

@ -0,0 +1,39 @@
package observer.nelle.roses.world;
import net.minecraft.registry.Registerable;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.util.Identifier;
import net.minecraft.world.gen.feature.ConfiguredFeature;
import net.minecraft.world.gen.feature.Feature;
import net.minecraft.world.gen.feature.FeatureConfig;
import net.minecraft.world.gen.feature.PlacedFeature;
import net.minecraft.world.gen.placementmodifier.PlacementModifier;
import observer.nelle.roses.RosesModKt;
import java.util.List;
public class RosesPlacedFeatures {
public static void bootstrap(Registerable<PlacedFeature> context) {
var configuredFeatures = context.getRegistryLookup(RegistryKeys.CONFIGURED_FEATURE);
}
public static RegistryKey<PlacedFeature> registerKey(String name) {
return RegistryKey.of(RegistryKeys.PLACED_FEATURE, Identifier.of(RosesModKt.MOD_ID, name));
}
private static void register(Registerable<PlacedFeature> context, RegistryKey<PlacedFeature> key, RegistryEntry<ConfiguredFeature<?, ?>> configuration,
List<PlacementModifier> modifiers) {
context.register(key, new PlacedFeature(configuration, List.copyOf(modifiers)));
}
// may not need this
private static <FC extends FeatureConfig, F extends Feature<FC>> void register(Registerable<PlacedFeature> context, RegistryKey<PlacedFeature> key,
RegistryEntry<ConfiguredFeature<?, ?>> configuration,
PlacementModifier... modifiers) {
register(context, key, configuration, List.of(modifiers));
}
}

View file

@ -0,0 +1,7 @@
package observer.nelle.roses.world.gen;
public class RosesWorldGeneration {
public static void generateRosesWorldGen() {
}
}

View file

@ -1,16 +0,0 @@
package observer.nelle.roses_mod;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
import net.minecraft.client.render.RenderLayer;
public class RosesModClient implements ClientModInitializer {
@Override
public void onInitializeClient() {
BlockRenderLayerMap.INSTANCE.putBlocks(RenderLayer.getCutout(), RosesBlocks.INSTANCE.getCyanRoseBush());
BlockRenderLayerMap.INSTANCE.putBlocks(RenderLayer.getCutout(), RosesBlocks.INSTANCE.getCyanRoseFlower());
BlockRenderLayerMap.INSTANCE.putBlocks(RenderLayer.getCutout(), RosesBlocks.INSTANCE.getPottedCyan());
BlockRenderLayerMap.INSTANCE.putBlocks(RenderLayer.getCutout(), RosesBlocks.INSTANCE.getPottedRose());
BlockRenderLayerMap.INSTANCE.putBlocks(RenderLayer.getCutout(), RosesBlocks.INSTANCE.getRoseFlower());
}
}

View file

@ -1,18 +0,0 @@
package observer.nelle.roses_mod.datagen;
import net.fabricmc.fabric.api.datagen.v1.DataGeneratorEntrypoint;
import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator;
public class RosesDataGenerator implements DataGeneratorEntrypoint {
@Override
public void onInitializeDataGenerator(FabricDataGenerator generator) {
FabricDataGenerator.Pack pack = generator.createPack();
// Adding a provider example:
//
pack.addProvider(RosesRecipeProvider::new);
pack.addProvider(RosesBlockTagProvider::new);
pack.addProvider(RosesLootTableProvider::new);
}
}

View file

@ -1,18 +0,0 @@
package observer.nelle.roses_mod.world.gen;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.util.Identifier;
import net.minecraft.world.gen.feature.PlacedFeature;
import observer.nelle.roses_mod.RosesModKt;
public class ModFlowerGeneration {
public static final RegistryKey<PlacedFeature> ROSE_FLOWER_PLACED_KEY = RegistryKey.of(RegistryKeys.PLACED_FEATURE, new Identifier("roses_mod","rose_flower"));
public static final RegistryKey<PlacedFeature> CYAN_ROSE_FLOWER_PLACED_KEY = RegistryKey.of(RegistryKeys.PLACED_FEATURE, new Identifier("roses_mod","cyan_rose_flower"));
public static final RegistryKey<PlacedFeature> CYAN_ROSE_BUSH_PLACED_KEY = RegistryKey.of(RegistryKeys.PLACED_FEATURE, new Identifier("roses_mod","cyan_rose_bush"));
public static void generateFlowers() {
RosesModKt.getLOGGER().debug("Registering Features...");
}
}

View file

@ -1,11 +1,8 @@
@file:Suppress( @file:Suppress(
"ktlint:standard:class-naming",
"ktlint:standard:filename",
"ktlint:standard:no-wildcard-imports", "ktlint:standard:no-wildcard-imports",
"ktlint:standard:package-name",
) )
package observer.nelle.roses_mod package observer.nelle.roses
import net.minecraft.block.* import net.minecraft.block.*
import net.minecraft.entity.effect.StatusEffects import net.minecraft.entity.effect.StatusEffects

View file

@ -1,11 +1,4 @@
@file:Suppress( package observer.nelle.roses
"ktlint:standard:class-naming",
"ktlint:standard:filename",
"ktlint:standard:no-wildcard-imports",
"ktlint:standard:package-name",
)
package observer.nelle.roses_mod
import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroupEntries import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroupEntries
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents

View file

@ -1,21 +1,14 @@
@file:Suppress( package observer.nelle.roses
"ktlint:standard:class-naming",
"ktlint:standard:filename",
"ktlint:standard:no-wildcard-imports",
"ktlint:standard:package-name",
)
package observer.nelle.roses_mod
import net.fabricmc.api.ModInitializer import net.fabricmc.api.ModInitializer
import observer.nelle.roses_mod.world.gen.ModFlowerGeneration import observer.nelle.roses.world.gen.RosesWorldGeneration
import org.slf4j.Logger import org.slf4j.Logger
import org.slf4j.LoggerFactory import org.slf4j.LoggerFactory
val LOGGER: Logger = LoggerFactory.getLogger("roses") val LOGGER: Logger = LoggerFactory.getLogger("roses")
const val MOD_ID = "roses_mod" const val MOD_ID = "roses_mod"
class roses_mod : ModInitializer { class Roses : ModInitializer {
override fun onInitialize() { override fun onInitialize() {
LOGGER.info("just like old times?") LOGGER.info("just like old times?")
@ -24,12 +17,11 @@ class roses_mod : ModInitializer {
* - biome modification * - biome modification
* */ * */
// worldgen first
ModFlowerGeneration.generateFlowers()
// blocks // blocks
RosesBlocks RosesBlocks
// creative tab entries // creative tab entries
RosesCreativeTab RosesCreativeTab
RosesWorldGeneration.generateRosesWorldGen()
} }
} }

View file

@ -0,0 +1,20 @@
package observer.nelle.roses
import net.fabricmc.api.ClientModInitializer
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap
import net.minecraft.client.render.RenderLayer
import observer.nelle.roses.RosesBlocks.cyanRoseBush
import observer.nelle.roses.RosesBlocks.cyanRoseFlower
import observer.nelle.roses.RosesBlocks.pottedCyan
import observer.nelle.roses.RosesBlocks.pottedRose
import observer.nelle.roses.RosesBlocks.roseFlower
class RosesModClient : ClientModInitializer {
override fun onInitializeClient() {
BlockRenderLayerMap.INSTANCE.putBlocks(RenderLayer.getCutout(), cyanRoseBush)
BlockRenderLayerMap.INSTANCE.putBlocks(RenderLayer.getCutout(), cyanRoseFlower)
BlockRenderLayerMap.INSTANCE.putBlocks(RenderLayer.getCutout(), pottedCyan)
BlockRenderLayerMap.INSTANCE.putBlocks(RenderLayer.getCutout(), pottedRose)
BlockRenderLayerMap.INSTANCE.putBlocks(RenderLayer.getCutout(), roseFlower)
}
}

View file

@ -20,12 +20,14 @@
"environment": "*", "environment": "*",
"entrypoints": { "entrypoints": {
"fabric-datagen": [ "fabric-datagen": [
"observer.nelle.roses_mod.datagen.RosesDataGenerator" "observer.nelle.roses.RosesDataGenerator"
], ],
"client": [ "client": [
"observer.nelle.roses_mod.RosesModClient" "observer.nelle.roses.RosesModClient"
], ],
"main": ["observer.nelle.roses_mod.roses_mod"] "main": [
"observer.nelle.roses.Roses"
]
}, },
"mixins": [ "mixins": [

View file

@ -2,7 +2,7 @@
// Its primary purpose is to define the subprojects. // Its primary purpose is to define the subprojects.
// It is also used for some aspects of project-wide configuration, like managing plugins, dependencies, etc. // It is also used for some aspects of project-wide configuration, like managing plugins, dependencies, etc.
// https://docs.gradle.org/current/userguide/settings_file_basics.html // https://docs.gradle.org/current/userguide/settings_file_basics.html
rootProject.name = "roses_mod" rootProject.name = "roses"
dependencyResolutionManagement { dependencyResolutionManagement {
// Use Maven Central as the default repository (where Gradle will download dependencies) in all subprojects. // Use Maven Central as the default repository (where Gradle will download dependencies) in all subprojects.