diff --git a/build.gradle b/build.gradle index fdcf19d..e33a6bb 100644 --- a/build.gradle +++ b/build.gradle @@ -28,7 +28,7 @@ dependencies { //modImplementation "io.github.prospector:modmenu:${project.mod_menu_version}" - modImplementation ("me.shedaniel:RoughlyEnoughItems-fabric:${project.rei_version}") { exclude(module: "ModMenu") } + //modImplementation ("me.shedaniel:RoughlyEnoughItems-fabric:${project.rei_version}") { exclude(module: "ModMenu") } implementation 'org.jetbrains:annotations:15.0' compileOnly "com.google.code.findbugs:jsr305:3.0.2" diff --git a/gradle.properties b/gradle.properties index c47c884..31361c6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,15 +1,15 @@ #Done to increase the memory available to gradle. org.gradle.jvmargs=-Xmx4G -version=1.3.0 +version=1.3.1 modid=flonters mod_name=Flonters -minecraft_version=1.18.1 -yarn_mappings=1.18.1+build.18 -loader_version=0.12.12 +minecraft_version=1.18.2 +yarn_mappings=1.18.2+build.2 +loader_version=0.13.3 #Fabric api -fabric_version=0.46.0+1.18 +fabric_version=0.47.10+1.18.2 mod_menu_version=3.0.1 rei_version=7.1.380 \ No newline at end of file diff --git a/src/main/java/mods/flonters/items/ItemFlonterFertilizer.java b/src/main/java/mods/flonters/items/ItemFlonterFertilizer.java index 969b51b..498b81d 100644 --- a/src/main/java/mods/flonters/items/ItemFlonterFertilizer.java +++ b/src/main/java/mods/flonters/items/ItemFlonterFertilizer.java @@ -41,7 +41,7 @@ public ActionResult useOnBlock(ItemUsageContext context) { BlockPos pos = context.getBlockPos(); final int range = 3; Block block = world.getBlockState(pos).getBlock(); - if (BlockTags.BAMBOO_PLANTABLE_ON.contains(block)) { + if (block.getRegistryEntry().isIn(BlockTags.BAMBOO_PLANTABLE_ON)) { if (!world.isClient) { List validPosList = new ArrayList<>(); diff --git a/src/main/java/mods/flonters/mixins/BiomeCategoryAccessor.java b/src/main/java/mods/flonters/mixins/BiomeCategoryAccessor.java new file mode 100644 index 0000000..e2feb69 --- /dev/null +++ b/src/main/java/mods/flonters/mixins/BiomeCategoryAccessor.java @@ -0,0 +1,11 @@ +package mods.flonters.mixins; + +import net.minecraft.world.biome.Biome; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(Biome.class) +public interface BiomeCategoryAccessor { + @Accessor("category") + Biome.Category getCategory(); +} diff --git a/src/main/java/mods/flonters/registry/FlontersGenerator.java b/src/main/java/mods/flonters/registry/FlontersGenerator.java index 07d39b1..47e6a74 100644 --- a/src/main/java/mods/flonters/registry/FlontersGenerator.java +++ b/src/main/java/mods/flonters/registry/FlontersGenerator.java @@ -1,96 +1,38 @@ package mods.flonters.registry; +import mods.flonters.mixins.BiomeCategoryAccessor; import mods.flonters.properties.FlontersProperties; import mods.flonters.world.FlontersFeature; import mods.flonters.world.FlontersFeatureConfig; import net.fabricmc.fabric.api.biome.v1.BiomeModifications; -import net.minecraft.util.registry.BuiltinRegistries; +import net.minecraft.util.Identifier; import net.minecraft.util.registry.Registry; +import net.minecraft.util.registry.RegistryKey; import net.minecraft.world.biome.Biome; import net.minecraft.world.gen.GenerationStep; -import net.minecraft.world.gen.feature.ConfiguredFeature; -import net.minecraft.world.gen.feature.Feature; +import net.minecraft.world.gen.feature.ConfiguredFeatures; import net.minecraft.world.gen.feature.PlacedFeature; +import net.minecraft.world.gen.feature.PlacedFeatures; import static mods.flonters.Flonters.getId; public class FlontersGenerator { - public static final Feature PATCH_O_FLONTERS = new FlontersFeature(); - public static final ConfiguredFeature CONFIGURED_PATCH = PATCH_O_FLONTERS.configure(new FlontersFeatureConfig()); - public static final PlacedFeature PLACED_PATCH = CONFIGURED_PATCH.withPlacement(); + public static final RegistryKey PATCH_O_FLONTERS = RegistryKey.of(Registry.PLACED_FEATURE_KEY, getId("patch_o_flonters")); public static void init() { - Registry.register(Registry.FEATURE, getId("patch_o_flonters"), PATCH_O_FLONTERS); - Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, getId("patch_o_flonters"), CONFIGURED_PATCH); - Registry.register(BuiltinRegistries.PLACED_FEATURE, getId("patch_o_flonters"), PLACED_PATCH); + Identifier id = getId("patch_o_flonters"); + FlontersFeature feature = Registry.register(Registry.FEATURE, id, new FlontersFeature()); + var cf = ConfiguredFeatures.register(id.toString(), feature, new FlontersFeatureConfig()); + PlacedFeatures.register(id.toString(), cf); + if (FlontersProperties.flonterPatchQuantity > 0) { BiomeModifications.addFeature(ctx -> { - Biome.Category category = ctx.getBiome().getCategory(); + Biome biome = ctx.getBiome(); + Biome.Category category = ((BiomeCategoryAccessor) (Object) biome).getCategory(); return category != Biome.Category.NETHER && category != Biome.Category.THEEND; }, GenerationStep.Feature.VEGETAL_DECORATION, - BuiltinRegistries.PLACED_FEATURE.getKey(PLACED_PATCH).orElseThrow()); - } - } - /* - private static final List checkedBiomes = new ArrayList<>(); - @Nullable - public static LegallyDistinctWorldGenConfig config; - - public static ConfiguredFeature configureFeature(Feature feature, F featureConfig, Decorator decorator, D decoratorConfig) { - Feature feature2 = feature instanceof FlowerFeature ? Feature.DECORATED : Feature.DECORATED; - return new ConfiguredFeature<>(feature2, new DecoratedFeatureConfig(() -> feature.configure(featureConfig), decorator.configure(decoratorConfig))); - } - - public static final Feature PATCH_O_FLONTERS = register("patch_o_flonters", new FlontersFeature(FlontersFeatureConfig.CODEC)); - - public static > F register(String name, F feature) { - return Registry.register(Registry.FEATURE, Flonters.getId(name), feature); - } - - private static void handleBiome(Biome biome, LegallyDistinctWorldGenConfig config) { - if (checkedBiomes.contains(biome)) { - return; - } - checkedBiomes.add(biome); - - if (biome.getCategory() != Biome.Category.NETHER && biome.getCategory() != Biome.Category.THEEND) { - addFeature(biome, Flonters.getId("patch_o_flonters"), GenerationStep.Feature.VEGETAL_DECORATION, config.getFlonterPatch()); - } - } - - private static void addFeature(Biome biome, Identifier identifier, GenerationStep.Feature feature, ConfiguredFeature configuredFeature) { - List>> features = biome.getGenerationSettings().getFeatures(); - - int stepIndex = feature.ordinal(); - - while (features.size() <= stepIndex) { - features.add(Lists.newArrayList()); - } - - List> stepList = features.get(feature.ordinal()); - if (stepList instanceof ImmutableList) { - features.set(feature.ordinal(), stepList = new ArrayList<>(stepList)); - } - - if (BuiltinRegistries.CONFIGURED_FEATURE.getKey(configuredFeature).isEmpty()) { - if (BuiltinRegistries.CONFIGURED_FEATURE.getOrEmpty(identifier).isPresent()) { - throw new RuntimeException("[Flonters] :) : " + identifier.toString()); - } else { - BuiltinRegistries.add(BuiltinRegistries.CONFIGURED_FEATURE, identifier, configuredFeature); - } + PATCH_O_FLONTERS); } - - stepList.add(() -> configuredFeature); } - - public static void init() { - config = new LegallyDistinctWorldGenConfig(configureFeature(PATCH_O_FLONTERS, new FlontersFeatureConfig(), Decorator.NOPE, NopeDecoratorConfig.DEFAULT)); - - for (Biome biome : BuiltinRegistries.BIOME) { - handleBiome(biome, config); - } - - RegistryEntryAddedCallback.event(BuiltinRegistries.BIOME).register((i, identifier, biome) -> handleBiome(biome, config)); - }*/ } diff --git a/src/main/resources/mixins.flonters.json b/src/main/resources/mixins.flonters.json index 8e49909..a2931ed 100644 --- a/src/main/resources/mixins.flonters.json +++ b/src/main/resources/mixins.flonters.json @@ -3,7 +3,8 @@ "package": "mods.flonters.mixins", "compatibilityLevel": "JAVA_8", "mixins": [ - "FlowerPotMixin" + "FlowerPotMixin", + "BiomeCategoryAccessor" ], "injectors": { "defaultRequire": 1