convert 1.20-20.4 module to kotlin as much as possible

This commit is contained in:
nelle 2024-12-22 02:14:08 -07:00
parent 7e8effa0e8
commit 1115e68dfa
7 changed files with 295 additions and 238 deletions

View file

@ -1,11 +1,11 @@
// 1.20.4 2024-12-21T18:37:31.73700589 Roses Mod/ // 1.20.4 2024-12-22T02:13:48.60704575 Roses Mod/
15c2ae2a52afeb92492c0a969eb6a834ee792028 data/roses_mod/worldgen/placed_feature/cyan_rose_common_placed.json
677e07b8d113f53c1702e801c4425096b607df9c data/roses_mod/worldgen/placed_feature/cyan_rose_rare_placed.json
5b0a542bdd658c02ee5ab5ed428997a6204165f1 data/roses_mod/worldgen/placed_feature/rose_rare_placed.json
6507e65a9e72c7bc6a97c3e996ceb82967b59311 data/roses_mod/worldgen/placed_feature/rose_common_placed.json
619f111dc2852139adb5c9ef798fe53fdae6d3c7 data/roses_mod/worldgen/placed_feature/cyan_rose_placed.json
b5132e15afd18ca7cfbde9bece704d9979cc0618 data/roses_mod/worldgen/placed_feature/rose_placed.json b5132e15afd18ca7cfbde9bece704d9979cc0618 data/roses_mod/worldgen/placed_feature/rose_placed.json
3f9e7faece178de35182469614527751f7447cd5 data/roses_mod/worldgen/configured_feature/cyan_rose_bush.json 15c2ae2a52afeb92492c0a969eb6a834ee792028 data/roses_mod/worldgen/placed_feature/cyan_rose_common_placed.json
1f0dac393835039f9ebe2a4c14c0b43fc62c5512 data/roses_mod/worldgen/configured_feature/rose_flower.json
134908f348dd2d85f329150816bf4cf5b8a1cfa9 data/roses_mod/worldgen/placed_feature/cyan_rose_bush_placed.json
68d13c6af6006b41d01201c517ecde01ae19f29e data/roses_mod/worldgen/configured_feature/cyan_rose_flower.json 68d13c6af6006b41d01201c517ecde01ae19f29e data/roses_mod/worldgen/configured_feature/cyan_rose_flower.json
677e07b8d113f53c1702e801c4425096b607df9c data/roses_mod/worldgen/placed_feature/cyan_rose_rare_placed.json
619f111dc2852139adb5c9ef798fe53fdae6d3c7 data/roses_mod/worldgen/placed_feature/cyan_rose_placed.json
6507e65a9e72c7bc6a97c3e996ceb82967b59311 data/roses_mod/worldgen/placed_feature/rose_common_placed.json
3f9e7faece178de35182469614527751f7447cd5 data/roses_mod/worldgen/configured_feature/cyan_rose_bush.json
134908f348dd2d85f329150816bf4cf5b8a1cfa9 data/roses_mod/worldgen/placed_feature/cyan_rose_bush_placed.json
1f0dac393835039f9ebe2a4c14c0b43fc62c5512 data/roses_mod/worldgen/configured_feature/rose_flower.json
5b0a542bdd658c02ee5ab5ed428997a6204165f1 data/roses_mod/worldgen/placed_feature/rose_rare_placed.json

View file

@ -1,30 +1,30 @@
package observer.nelle.roses.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.RosesBlocks; 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
import java.util.concurrent.CompletableFuture
import java.util.concurrent.CompletableFuture; class RosesBlockTagProvider(
output: FabricDataOutput,
public class RosesBlockTagProvider extends FabricTagProvider.BlockTagProvider { registriesFuture: CompletableFuture<RegistryWrapper.WrapperLookup?>?,
public RosesBlockTagProvider(FabricDataOutput output, CompletableFuture<RegistryWrapper.WrapperLookup> registriesFuture) { ) : FabricTagProvider.BlockTagProvider(output, registriesFuture) {
super(output, registriesFuture); override fun configure(wrapperLookup: RegistryWrapper.WrapperLookup) {
}
@Override
protected void configure(RegistryWrapper.WrapperLookup wrapperLookup) {
getOrCreateTagBuilder(BlockTags.TALL_FLOWERS) getOrCreateTagBuilder(BlockTags.TALL_FLOWERS)
.add(RosesBlocks.INSTANCE.getCyanRoseBush()) .add(cyanRoseBush)
;
getOrCreateTagBuilder(BlockTags.SMALL_FLOWERS) getOrCreateTagBuilder(BlockTags.SMALL_FLOWERS)
.add(RosesBlocks.INSTANCE.getRoseFlower()) .add(roseFlower)
.add(RosesBlocks.INSTANCE.getCyanRoseFlower()) .add(cyanRoseFlower)
;
getOrCreateTagBuilder(BlockTags.FLOWER_POTS) getOrCreateTagBuilder(BlockTags.FLOWER_POTS)
.add(RosesBlocks.INSTANCE.getPottedRose()) .add(pottedRose)
.add(RosesBlocks.INSTANCE.getPottedCyan()) .add(pottedCyan)
;
} }
} }

View file

@ -1,43 +1,61 @@
package observer.nelle.roses.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
import net.minecraft.block.Block; import net.minecraft.block.Block
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks
import net.minecraft.enchantment.Enchantments; import net.minecraft.enchantment.Enchantments
import net.minecraft.item.Item; import net.minecraft.loot.LootTable
import net.minecraft.loot.LootTable; import net.minecraft.loot.entry.ItemEntry
import net.minecraft.loot.entry.ItemEntry; import net.minecraft.loot.function.ApplyBonusLootFunction
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.RosesBlocks.cyanRoseBush
import observer.nelle.roses.RosesBlocks; import observer.nelle.roses.RosesBlocks.cyanRoseFlower
import observer.nelle.roses.RosesBlocks.pottedCyan
import observer.nelle.roses.RosesBlocks.pottedRose
import observer.nelle.roses.RosesBlocks.roseFlower
import java.util.concurrent.CompletableFuture
import java.util.Objects; class RosesLootTableProvider(
import java.util.concurrent.CompletableFuture; dataOutput: FabricDataOutput?,
registryLookup: CompletableFuture<RegistryWrapper.WrapperLookup?>?,
) : FabricBlockLootTableProvider(dataOutput) {
override fun generate() {
addDrop(roseFlower)
addDrop(cyanRoseFlower)
public class RosesLootTableProvider extends FabricBlockLootTableProvider { addPottedPlantDrops(pottedRose)
public RosesLootTableProvider(FabricDataOutput dataOutput, CompletableFuture<RegistryWrapper.WrapperLookup> registryLookup) { addPottedPlantDrops(pottedCyan)
super(dataOutput);
addDrop(
Blocks.ROSE_BUSH,
roseBushDrops(
Blocks.ROSE_BUSH,
roseFlower,
2.0f,
5.0f,
),
)
addDrop(cyanRoseBush, roseBushDrops(cyanRoseBush!!, cyanRoseFlower, 2.0f, 5.0f))
} }
@Override private fun roseBushDrops(
public void generate() { input: Block,
addDrop(RosesBlocks.INSTANCE.getRoseFlower()); output: Block?,
addDrop(RosesBlocks.INSTANCE.getCyanRoseFlower()); min: Float,
max: Float,
addPottedPlantDrops(RosesBlocks.INSTANCE.getPottedRose()); ): LootTable.Builder =
addPottedPlantDrops(RosesBlocks.INSTANCE.getPottedCyan()); dropsWithShears(
input,
addDrop(Blocks.ROSE_BUSH, roseBushDrops(Blocks.ROSE_BUSH, Objects.requireNonNull(RosesBlocks.INSTANCE.getRoseFlower()).asItem(), 2.0F, 5.0F)); this
addDrop(RosesBlocks.INSTANCE.getCyanRoseBush(), roseBushDrops(RosesBlocks.INSTANCE.getCyanRoseBush(), Objects.requireNonNull(RosesBlocks.INSTANCE.getCyanRoseFlower()).asItem(), 2.0F, 5.0F)); .applyExplosionDecay(
} input,
ItemEntry
public LootTable.Builder roseBushDrops(Block input, Item output, Float min, Float max) { .builder(output)
return dropsWithShears(input, this
.applyExplosionDecay(input, ItemEntry.builder(output)
.apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(min, max))) .apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(min, max)))
.apply(ApplyBonusLootFunction.oreDrops(Enchantments.FORTUNE)))); .apply(ApplyBonusLootFunction.oreDrops(Enchantments.FORTUNE)),
} ),
)
} }

View file

@ -1,27 +1,49 @@
package observer.nelle.roses.datagen; @file:Suppress("ktlint:standard:no-wildcard-imports")
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; package observer.nelle.roses.datagen
import net.fabricmc.fabric.api.datagen.v1.provider.FabricRecipeProvider;
import net.minecraft.data.server.recipe.RecipeExporter;
import net.minecraft.item.Items;
import net.minecraft.recipe.book.RecipeCategory;
import net.minecraft.registry.RegistryWrapper;
import observer.nelle.roses.RosesBlocks;
import java.util.Objects; import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput
import java.util.concurrent.CompletableFuture; import net.fabricmc.fabric.api.datagen.v1.provider.FabricRecipeProvider
import net.minecraft.data.server.recipe.RecipeExporter
import net.minecraft.item.Items
import net.minecraft.recipe.book.RecipeCategory
import net.minecraft.registry.RegistryWrapper
import observer.nelle.roses.RosesBlocks.cyanRoseBush
import observer.nelle.roses.RosesBlocks.cyanRoseFlower
import observer.nelle.roses.RosesBlocks.roseFlower
import java.util.*
import java.util.concurrent.CompletableFuture
public class RosesRecipeProvider extends FabricRecipeProvider { class RosesRecipeProvider(
public RosesRecipeProvider(FabricDataOutput output, CompletableFuture<RegistryWrapper.WrapperLookup> registriesFuture) { output: FabricDataOutput,
super(output); registriesFuture: CompletableFuture<RegistryWrapper.WrapperLookup?>?,
} ) : FabricRecipeProvider(output) {
override fun generate(recipeExporter: RecipeExporter) {
offerShapelessRecipe(
recipeExporter,
Items.RED_DYE,
Objects.requireNonNull(
roseFlower,
),
"dye",
2,
)
offerShapelessRecipe(
recipeExporter,
Items.CYAN_DYE,
Objects.requireNonNull(
cyanRoseFlower,
),
"dye",
2,
)
@Override offer2x2CompactingRecipe(recipeExporter, RecipeCategory.DECORATIONS, Items.ROSE_BUSH, roseFlower)
public void generate(RecipeExporter recipeExporter) { offer2x2CompactingRecipe(
offerShapelessRecipe(recipeExporter, Items.RED_DYE, Objects.requireNonNull(RosesBlocks.INSTANCE.getRoseFlower()), "dye", 2); recipeExporter,
offerShapelessRecipe(recipeExporter, Items.CYAN_DYE, Objects.requireNonNull(RosesBlocks.INSTANCE.getCyanRoseFlower()), "dye", 2); RecipeCategory.DECORATIONS,
cyanRoseBush,
offer2x2CompactingRecipe(recipeExporter, RecipeCategory.DECORATIONS, Items.ROSE_BUSH, RosesBlocks.INSTANCE.getRoseFlower()); cyanRoseFlower,
offer2x2CompactingRecipe(recipeExporter, RecipeCategory.DECORATIONS, Objects.requireNonNull(RosesBlocks.INSTANCE.getCyanRoseBush()).asItem(), RosesBlocks.INSTANCE.getCyanRoseFlower()); )
} }
} }

View file

@ -1,25 +1,22 @@
package observer.nelle.roses.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.FabricDynamicRegistryProvider; import net.fabricmc.fabric.api.datagen.v1.provider.FabricDynamicRegistryProvider
import net.minecraft.registry.RegistryKeys; import net.minecraft.registry.RegistryKeys
import net.minecraft.registry.RegistryWrapper; import net.minecraft.registry.RegistryWrapper
import java.util.concurrent.CompletableFuture
import java.util.concurrent.CompletableFuture; class RosesRegistryGenerator(
output: FabricDataOutput?,
public class RosesRegistryGenerator extends FabricDynamicRegistryProvider { registriesFuture: CompletableFuture<RegistryWrapper.WrapperLookup?>?,
public RosesRegistryGenerator(FabricDataOutput output, CompletableFuture<RegistryWrapper.WrapperLookup> registriesFuture) { ) : FabricDynamicRegistryProvider(output, registriesFuture) {
super(output, registriesFuture); override fun configure(
registries: RegistryWrapper.WrapperLookup,
entries: Entries,
) {
entries.addAll(registries.getWrapperOrThrow(RegistryKeys.CONFIGURED_FEATURE))
entries.addAll(registries.getWrapperOrThrow(RegistryKeys.PLACED_FEATURE))
} }
@Override override fun getName(): String = ""
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

@ -1,21 +1,24 @@
package observer.nelle.roses.world.gen; package observer.nelle.roses.world.gen
import net.fabricmc.fabric.api.biome.v1.BiomeModifications; import net.fabricmc.fabric.api.biome.v1.BiomeModifications
import net.fabricmc.fabric.api.biome.v1.BiomeSelectors; import net.fabricmc.fabric.api.biome.v1.BiomeSelectors
import net.minecraft.world.biome.BiomeKeys; import net.minecraft.world.biome.BiomeKeys
import net.minecraft.world.gen.GenerationStep; import net.minecraft.world.gen.GenerationStep
import observer.nelle.roses.world.RosesPlacedFeatures; import observer.nelle.roses.world.RosesPlacedFeatures
public class RosesVegetationGeneration { object RosesVegetationGeneration {
public static void generateVegetation() { fun generateVegetation() {
BiomeModifications.addFeature( BiomeModifications.addFeature(
BiomeSelectors.includeByKey( BiomeSelectors.includeByKey(
BiomeKeys.FOREST, BiomeKeys.FOREST,
BiomeKeys.FLOWER_FOREST, BiomeKeys.FLOWER_FOREST,
BiomeKeys.BIRCH_FOREST, BiomeKeys.BIRCH_FOREST,
BiomeKeys.OLD_GROWTH_BIRCH_FOREST, BiomeKeys.OLD_GROWTH_BIRCH_FOREST,
BiomeKeys.DARK_FOREST), BiomeKeys.DARK_FOREST,
GenerationStep.Feature.VEGETAL_DECORATION, RosesPlacedFeatures.cyanRoseBushPlacedKey); ),
GenerationStep.Feature.VEGETAL_DECORATION,
RosesPlacedFeatures.cyanRoseBushPlacedKey,
)
// regular // regular
BiomeModifications.addFeature( BiomeModifications.addFeature(
@ -37,10 +40,14 @@ public class RosesVegetationGeneration {
BiomeKeys.WINDSWEPT_FOREST, BiomeKeys.WINDSWEPT_FOREST,
BiomeKeys.WINDSWEPT_GRAVELLY_HILLS, BiomeKeys.WINDSWEPT_GRAVELLY_HILLS,
BiomeKeys.RIVER, BiomeKeys.RIVER,
BiomeKeys.FROZEN_RIVER), BiomeKeys.FROZEN_RIVER,
GenerationStep.Feature.VEGETAL_DECORATION, RosesPlacedFeatures.cyanRosePlacedKey); ),
GenerationStep.Feature.VEGETAL_DECORATION,
RosesPlacedFeatures.cyanRosePlacedKey,
)
BiomeModifications.addFeature(BiomeSelectors.includeByKey( BiomeModifications.addFeature(
BiomeSelectors.includeByKey(
BiomeKeys.PLAINS, BiomeKeys.PLAINS,
BiomeKeys.SUNFLOWER_PLAINS, BiomeKeys.SUNFLOWER_PLAINS,
BiomeKeys.MEADOW, // https://minecraft.wiki/w/Flower#Flower_gradients BiomeKeys.MEADOW, // https://minecraft.wiki/w/Flower#Flower_gradients
@ -58,8 +65,11 @@ public class RosesVegetationGeneration {
BiomeKeys.WINDSWEPT_FOREST, BiomeKeys.WINDSWEPT_FOREST,
BiomeKeys.WINDSWEPT_GRAVELLY_HILLS, BiomeKeys.WINDSWEPT_GRAVELLY_HILLS,
BiomeKeys.RIVER, BiomeKeys.RIVER,
BiomeKeys.FROZEN_RIVER), BiomeKeys.FROZEN_RIVER,
GenerationStep.Feature.VEGETAL_DECORATION, RosesPlacedFeatures.rosePlacedKey); ),
GenerationStep.Feature.VEGETAL_DECORATION,
RosesPlacedFeatures.rosePlacedKey,
)
// rarer // rarer
BiomeModifications.addFeature( BiomeModifications.addFeature(
@ -79,11 +89,14 @@ public class RosesVegetationGeneration {
BiomeKeys.DESERT, BiomeKeys.DESERT,
BiomeKeys.ICE_SPIKES, BiomeKeys.ICE_SPIKES,
BiomeKeys.DRIPSTONE_CAVES, BiomeKeys.DRIPSTONE_CAVES,
BiomeKeys.DEEP_DARK BiomeKeys.DEEP_DARK,
), ),
GenerationStep.Feature.VEGETAL_DECORATION, RosesPlacedFeatures.cyanRoseRarerPlacedKey); GenerationStep.Feature.VEGETAL_DECORATION,
RosesPlacedFeatures.cyanRoseRarerPlacedKey,
)
BiomeModifications.addFeature(BiomeSelectors.includeByKey( BiomeModifications.addFeature(
BiomeSelectors.includeByKey(
BiomeKeys.BEACH, BiomeKeys.BEACH,
BiomeKeys.SNOWY_BEACH, BiomeKeys.SNOWY_BEACH,
BiomeKeys.STONY_SHORE, BiomeKeys.STONY_SHORE,
@ -99,9 +112,11 @@ public class RosesVegetationGeneration {
BiomeKeys.DESERT, BiomeKeys.DESERT,
BiomeKeys.ICE_SPIKES, BiomeKeys.ICE_SPIKES,
BiomeKeys.DRIPSTONE_CAVES, BiomeKeys.DRIPSTONE_CAVES,
BiomeKeys.DEEP_DARK BiomeKeys.DEEP_DARK,
), ),
GenerationStep.Feature.VEGETAL_DECORATION, RosesPlacedFeatures.roseRarerPlacedKey); GenerationStep.Feature.VEGETAL_DECORATION,
RosesPlacedFeatures.roseRarerPlacedKey,
)
// more common // more common
BiomeModifications.addFeature( BiomeModifications.addFeature(
@ -111,18 +126,23 @@ public class RosesVegetationGeneration {
BiomeKeys.SPARSE_JUNGLE, BiomeKeys.SPARSE_JUNGLE,
BiomeKeys.SAVANNA, BiomeKeys.SAVANNA,
BiomeKeys.SAVANNA_PLATEAU, BiomeKeys.SAVANNA_PLATEAU,
BiomeKeys.WINDSWEPT_SAVANNA BiomeKeys.WINDSWEPT_SAVANNA,
), ),
GenerationStep.Feature.VEGETAL_DECORATION, RosesPlacedFeatures.cyanRoseCommonPlacedKey); GenerationStep.Feature.VEGETAL_DECORATION,
RosesPlacedFeatures.cyanRoseCommonPlacedKey,
)
BiomeModifications.addFeature(BiomeSelectors.includeByKey( BiomeModifications.addFeature(
BiomeSelectors.includeByKey(
BiomeKeys.JUNGLE, BiomeKeys.JUNGLE,
BiomeKeys.BAMBOO_JUNGLE, BiomeKeys.BAMBOO_JUNGLE,
BiomeKeys.SPARSE_JUNGLE, BiomeKeys.SPARSE_JUNGLE,
BiomeKeys.SAVANNA, BiomeKeys.SAVANNA,
BiomeKeys.SAVANNA_PLATEAU, BiomeKeys.SAVANNA_PLATEAU,
BiomeKeys.WINDSWEPT_SAVANNA BiomeKeys.WINDSWEPT_SAVANNA,
), ),
GenerationStep.Feature.VEGETAL_DECORATION, RosesPlacedFeatures.roseCommonPlacedKey); GenerationStep.Feature.VEGETAL_DECORATION,
RosesPlacedFeatures.roseCommonPlacedKey,
)
} }
} }

View file

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