diff --git a/build.gradle b/build.gradle index 3e8abac5..0d53b23b 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { } plugins { - id "architectury-plugin" version "3.4-SNAPSHOT" + id "architectury-plugin" version "3.4.130" id "dev.architectury.loom" version "0.11.0-SNAPSHOT" apply false id "org.cadixdev.licenser" version "0.6.1" id "com.matthewprenger.cursegradle" version "1.4.0" apply false diff --git a/common/src/main/java/dev/architectury/hooks/level/biome/BiomeHooks.java b/common/src/main/java/dev/architectury/hooks/level/biome/BiomeHooks.java index ce244b82..3462dc1f 100644 --- a/common/src/main/java/dev/architectury/hooks/level/biome/BiomeHooks.java +++ b/common/src/main/java/dev/architectury/hooks/level/biome/BiomeHooks.java @@ -20,7 +20,6 @@ package dev.architectury.hooks.level.biome; import net.minecraft.core.Holder; -import net.minecraft.core.HolderSet; import net.minecraft.sounds.Music; import net.minecraft.sounds.SoundEvent; import net.minecraft.world.entity.EntityType; @@ -30,7 +29,6 @@ import net.minecraft.world.level.biome.Biome.BiomeCategory; import net.minecraft.world.level.biome.BiomeSpecialEffects.GrassColorModifier; import net.minecraft.world.level.levelgen.GenerationStep; import net.minecraft.world.level.levelgen.carver.ConfiguredWorldCarver; -import net.minecraft.world.level.levelgen.feature.ConfiguredFeature; import net.minecraft.world.level.levelgen.placement.PlacedFeature; import org.jetbrains.annotations.Nullable; @@ -38,7 +36,6 @@ import java.util.List; import java.util.Map; import java.util.Optional; import java.util.OptionalInt; -import java.util.function.Supplier; public final class BiomeHooks { public static BiomeProperties getBiomeProperties(Biome biome) { @@ -370,8 +367,8 @@ public final class BiomeHooks { } @Override - public List> getFeatures() { - return settings.features(); + public List>> getFeatures() { + return (List>>) (List) settings.features(); } } diff --git a/common/src/main/java/dev/architectury/hooks/level/biome/GenerationProperties.java b/common/src/main/java/dev/architectury/hooks/level/biome/GenerationProperties.java index 92fb0138..a4693e77 100644 --- a/common/src/main/java/dev/architectury/hooks/level/biome/GenerationProperties.java +++ b/common/src/main/java/dev/architectury/hooks/level/biome/GenerationProperties.java @@ -20,30 +20,73 @@ package dev.architectury.hooks.level.biome; import net.minecraft.core.Holder; -import net.minecraft.core.HolderSet; +import net.minecraft.data.BuiltinRegistries; +import net.minecraft.resources.ResourceKey; import net.minecraft.world.level.levelgen.GenerationStep; import net.minecraft.world.level.levelgen.carver.ConfiguredWorldCarver; import net.minecraft.world.level.levelgen.placement.PlacedFeature; -import org.jetbrains.annotations.ApiStatus; import java.util.List; +import java.util.Optional; public interface GenerationProperties { Iterable>> getCarvers(GenerationStep.Carving carving); Iterable> getFeatures(GenerationStep.Decoration decoration); - List> getFeatures(); + List>> getFeatures(); interface Mutable extends GenerationProperties { - @ApiStatus.Experimental - Mutable addFeature(GenerationStep.Decoration decoration, PlacedFeature feature); + @Deprecated + default Mutable addFeature(GenerationStep.Decoration decoration, PlacedFeature feature) { + Optional> key = BuiltinRegistries.PLACED_FEATURE.getResourceKey(feature); + if (key.isPresent()) { + return addFeature(decoration, BuiltinRegistries.PLACED_FEATURE.getHolderOrThrow(key.get())); + } else { + return addFeature(decoration, Holder.direct(feature)); + } + } - Mutable addCarver(GenerationStep.Carving carving, ConfiguredWorldCarver feature); + Mutable addFeature(GenerationStep.Decoration decoration, Holder feature); - @ApiStatus.Experimental - Mutable removeFeature(GenerationStep.Decoration decoration, PlacedFeature feature); + @Deprecated + default Mutable addCarver(GenerationStep.Carving carving, ConfiguredWorldCarver feature) { + Optional>> key = BuiltinRegistries.CONFIGURED_CARVER.getResourceKey(feature); + if (key.isPresent()) { + return addCarver(carving, BuiltinRegistries.CONFIGURED_CARVER.getHolderOrThrow(key.get())); + } else { + return addCarver(carving, Holder.direct(feature)); + } + } - Mutable removeCarver(GenerationStep.Carving carving, ConfiguredWorldCarver feature); + Mutable addCarver(GenerationStep.Carving carving, Holder> feature); + + @Deprecated + default Mutable removeFeature(GenerationStep.Decoration decoration, PlacedFeature feature) { + Optional> key = BuiltinRegistries.PLACED_FEATURE.getResourceKey(feature); + if (key.isPresent()) { + return removeFeature(decoration, key.get()); + } else { + // This is dumb + System.err.println("Attempted to remove a dynamic feature with a deprecated builtin method!"); + return this; + } + } + + Mutable removeFeature(GenerationStep.Decoration decoration, ResourceKey feature); + + @Deprecated + default Mutable removeCarver(GenerationStep.Carving carving, ConfiguredWorldCarver feature) { + Optional>> key = BuiltinRegistries.CONFIGURED_CARVER.getResourceKey(feature); + if (key.isPresent()) { + return removeCarver(carving, key.get()); + } else { + // This is dumb + System.err.println("Attempted to remove a dynamic carver with a deprecated builtin method!"); + return this; + } + } + + Mutable removeCarver(GenerationStep.Carving carving, ResourceKey> feature); } } diff --git a/fabric/build.gradle b/fabric/build.gradle index 21d2c203..4224b1c9 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -105,7 +105,7 @@ curseforge { releaseType = "$rootProject.cf_type" changelogType = "html" changelog = releaseChangelog() - // addGameVersion "1.18.1" + addGameVersion "1.18.2" addGameVersion "1.18-Snapshot" addGameVersion "Java 17" addGameVersion "Fabric" diff --git a/fabric/src/main/java/dev/architectury/registry/level/biome/fabric/BiomeModificationsImpl.java b/fabric/src/main/java/dev/architectury/registry/level/biome/fabric/BiomeModificationsImpl.java index b8bef834..b44a1249 100644 --- a/fabric/src/main/java/dev/architectury/registry/level/biome/fabric/BiomeModificationsImpl.java +++ b/fabric/src/main/java/dev/architectury/registry/level/biome/fabric/BiomeModificationsImpl.java @@ -21,12 +21,15 @@ package dev.architectury.registry.level.biome.fabric; import com.google.common.base.Predicates; import com.google.common.collect.Lists; +import com.mojang.datafixers.util.Either; import dev.architectury.hooks.level.biome.*; import dev.architectury.registry.level.biome.BiomeModifications.BiomeContext; import net.fabricmc.fabric.api.biome.v1.BiomeModification; import net.fabricmc.fabric.api.biome.v1.BiomeModificationContext; import net.fabricmc.fabric.api.biome.v1.BiomeSelectionContext; import net.fabricmc.fabric.api.biome.v1.ModificationPhase; +import net.minecraft.core.Holder; +import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraft.sounds.Music; import net.minecraft.sounds.SoundEvent; @@ -139,26 +142,36 @@ public class BiomeModificationsImpl { } @Override - public Mutable addFeature(GenerationStep.Decoration decoration, PlacedFeature feature) { - this.context.addBuiltInFeature(decoration, feature); + public Mutable addFeature(GenerationStep.Decoration decoration, Holder feature) { + Either, PlacedFeature> unwrap = feature.unwrap(); + if (unwrap.left().isPresent()) { + this.context.addFeature(decoration, unwrap.left().get()); + } else { + this.context.addBuiltInFeature(decoration, unwrap.right().get()); + } return this; } @Override - public Mutable addCarver(GenerationStep.Carving carving, ConfiguredWorldCarver feature) { - context.addBuiltInCarver(carving, feature); + public Mutable addCarver(GenerationStep.Carving carving, Holder> feature) { + Either>, ConfiguredWorldCarver> unwrap = feature.unwrap(); + if (unwrap.left().isPresent()) { + this.context.addCarver(carving, unwrap.left().get()); + } else { + this.context.addBuiltInCarver(carving, unwrap.right().get()); + } return this; } @Override - public Mutable removeFeature(GenerationStep.Decoration decoration, PlacedFeature feature) { - context.removeBuiltInFeature(decoration, feature); + public Mutable removeFeature(GenerationStep.Decoration decoration, ResourceKey feature) { + context.removeFeature(decoration, feature); return this; } @Override - public Mutable removeCarver(GenerationStep.Carving carving, ConfiguredWorldCarver feature) { - context.removeBuiltInCarver(carving, feature); + public Mutable removeCarver(GenerationStep.Carving carving, ResourceKey> feature) { + context.removeCarver(carving, feature); return this; } } diff --git a/forge/build.gradle b/forge/build.gradle index 72f52b37..78c5dbc3 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -103,7 +103,7 @@ curseforge { releaseType = "$rootProject.cf_type" changelogType = "html" changelog = releaseChangelog() - // addGameVersion "1.18.2" + addGameVersion "1.18.2" addGameVersion "Java 17" addGameVersion "Forge" mainArtifact(remapJar.archivePath) { diff --git a/forge/src/main/java/dev/architectury/mixin/forge/MixinClientLevel.java b/forge/src/main/java/dev/architectury/mixin/forge/MixinClientLevel.java index 0ec2c4f4..856c2105 100644 --- a/forge/src/main/java/dev/architectury/mixin/forge/MixinClientLevel.java +++ b/forge/src/main/java/dev/architectury/mixin/forge/MixinClientLevel.java @@ -21,6 +21,7 @@ package dev.architectury.mixin.forge; import dev.architectury.event.events.client.ClientTickEvent; import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.core.Holder; import net.minecraft.resources.ResourceKey; import net.minecraft.util.profiling.ProfilerFiller; import net.minecraft.world.level.Level; @@ -35,7 +36,7 @@ import java.util.function.Supplier; @Mixin(ClientLevel.class) public abstract class MixinClientLevel extends Level { - protected MixinClientLevel(WritableLevelData worldInfo, ResourceKey dimension, DimensionType dimensionType, Supplier profiler, boolean isRemote, boolean isDebug, long seed) { + protected MixinClientLevel(WritableLevelData worldInfo, ResourceKey dimension, Holder dimensionType, Supplier profiler, boolean isRemote, boolean isDebug, long seed) { super(worldInfo, dimension, dimensionType, profiler, isRemote, isDebug, seed); } diff --git a/forge/src/main/java/dev/architectury/registry/block/forge/BlockPropertiesImpl.java b/forge/src/main/java/dev/architectury/registry/block/forge/BlockPropertiesImpl.java index 74620dac..cf5fa146 100644 --- a/forge/src/main/java/dev/architectury/registry/block/forge/BlockPropertiesImpl.java +++ b/forge/src/main/java/dev/architectury/registry/block/forge/BlockPropertiesImpl.java @@ -20,7 +20,6 @@ package dev.architectury.registry.block.forge; import dev.architectury.registry.block.BlockProperties; -import dev.architectury.registry.block.ToolType; import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.Material; diff --git a/forge/src/main/java/dev/architectury/registry/level/biome/forge/BiomeModificationsImpl.java b/forge/src/main/java/dev/architectury/registry/level/biome/forge/BiomeModificationsImpl.java index 59a465e5..eecb1533 100644 --- a/forge/src/main/java/dev/architectury/registry/level/biome/forge/BiomeModificationsImpl.java +++ b/forge/src/main/java/dev/architectury/registry/level/biome/forge/BiomeModificationsImpl.java @@ -23,6 +23,8 @@ import com.google.common.collect.Lists; import dev.architectury.forge.ArchitecturyForge; import dev.architectury.hooks.level.biome.*; import dev.architectury.registry.level.biome.BiomeModifications.BiomeContext; +import net.minecraft.core.Holder; +import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.MobCategory; @@ -45,7 +47,6 @@ import java.util.Map; import java.util.function.BiConsumer; import java.util.function.BiPredicate; import java.util.function.Predicate; -import java.util.function.Supplier; @Mod.EventBusSubscriber(modid = ArchitecturyForge.MOD_ID) public class BiomeModificationsImpl { @@ -150,18 +151,18 @@ public class BiomeModificationsImpl { } @Override - public @NotNull List>> getCarvers(GenerationStep.Carving carving) { + public Iterable>> getCarvers(GenerationStep.Carving carving) { return generation.getCarvers(carving); } - + @Override - public List> getFeatures(GenerationStep.Decoration decoration) { + public Iterable> getFeatures(GenerationStep.Decoration decoration) { return generation.getFeatures(decoration); } - + @Override - public @NotNull List>> getFeatures() { - return generation.features; + public List>> getFeatures() { + return (List>>) (List) generation.features; } } @@ -305,26 +306,26 @@ public class BiomeModificationsImpl { } @Override - public Mutable addFeature(GenerationStep.Decoration decoration, PlacedFeature feature) { + public Mutable addFeature(GenerationStep.Decoration decoration, Holder feature) { generation.addFeature(decoration, feature); return this; } @Override - public Mutable addCarver(GenerationStep.Carving carving, ConfiguredWorldCarver feature) { + public Mutable addCarver(GenerationStep.Carving carving, Holder> feature) { generation.addCarver(carving, feature); return this; } @Override - public Mutable removeFeature(GenerationStep.Decoration decoration, PlacedFeature feature) { - generation.getFeatures(decoration).removeIf(supplier -> supplier.get() == feature); + public Mutable removeFeature(GenerationStep.Decoration decoration, ResourceKey feature) { + generation.getFeatures(decoration).removeIf(supplier -> supplier.is(feature)); return this; } @Override - public Mutable removeCarver(GenerationStep.Carving carving, ConfiguredWorldCarver feature) { - generation.getCarvers(carving).removeIf(supplier -> supplier.get() == feature); + public Mutable removeCarver(GenerationStep.Carving carving, ResourceKey> feature) { + generation.getCarvers(carving).removeIf(supplier -> supplier.is(feature)); return this; } } diff --git a/gradle.properties b/gradle.properties index 24b5d0b9..7f6510e1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,10 +1,10 @@ org.gradle.jvmargs=-Xmx3G org.gradle.daemon=false -forgeEnabled=false +forgeEnabled=true -minecraft_version=1.18.2-rc1 -supported_version=1.18.2-rc1 +minecraft_version=1.18.2 +supported_version=1.18.2 cf_type=beta @@ -17,4 +17,4 @@ fabric_loader_version=0.13.2 fabric_api_version=0.47.8+1.18.2 mod_menu_version=3.0.0 -forge_version=38.0.17 +forge_version=40.0.1 diff --git a/settings.gradle b/settings.gradle index 752c1f7d..938c20fb 100644 --- a/settings.gradle +++ b/settings.gradle @@ -14,9 +14,9 @@ if (JavaVersion.current().ordinal() + 1 < 17) { include("common") include("fabric") -//include("forge") +include("forge") include("testmod-common") include("testmod-fabric") -//include("testmod-forge") +include("testmod-forge") rootProject.name = "architectury"