From 1697c842492f6fde64b6a96cd64819337c0d06bf Mon Sep 17 00:00:00 2001 From: BlayTheNinth <1933180+BlayTheNinth@users.noreply.github.com> Date: Thu, 6 Jun 2024 16:39:02 +0200 Subject: [PATCH] wip: Update to Minecraft 1.21 Fabric only so far and BalmModels has a bunch of open TODOs pending Fabric update --- .gitignore | 2 +- .../src/main/groovy/multiloader-common.gradle | 7 ++ common/build.gradle | 29 ------- .../blay09/mods/balm/api/DeferredObject.java | 16 ++-- .../balm/api/client/rendering/BalmModels.java | 22 +++--- .../mods/balm/api/tag/BalmItemTags.java | 62 +++++++-------- .../rendering/AbstractCachedDynamicModel.java | 26 +++---- .../mods/balm/config/ExampleConfigData.java | 2 +- .../mods/balm/mixin/ModelBakeryAccessor.java | 13 ++++ common/src/main/resources/balm.mixins.json | 1 + .../blay09/mods/balm/fabric/FabricBalm.java | 4 +- .../balm/fabric/FabricBalmRegistries.java | 2 +- .../balm/fabric/client/FabricBalmClient.java | 6 +- .../client/rendering/FabricBalmModels.java | 76 +++++++++---------- .../rendering/FabricCachedDynamicModel.java | 5 +- .../fabric/config/FabricConfigLoader.java | 4 +- .../net/blay09/mods/balm/mixin/GuiMixin.java | 9 ++- .../mods/balm/mixin/ModelBakeryMixin.java | 11 +-- .../mods/balm/mixin/ServerPlayerMixin.java | 14 ++-- .../data/c/tags/{items => item}/eggs.json | 0 .../data/c/tags/{items => item}/nuggets.json | 0 .../c/tags/{items => item}/nuggets/gold.json | 0 .../c/tags/{items => item}/nuggets/iron.json | 0 .../data/c/tags/{items => item}/stones.json | 0 fabric/src/main/resources/fabric.mod.json | 2 +- .../c/tags/{items => item}/chests/wooden.json | 0 .../c/tags/{items => item}/cooking_oil.json | 0 .../data/c/tags/{items => item}/dyes.json | 0 .../c/tags/{items => item}/dyes/black.json | 0 .../c/tags/{items => item}/dyes/blue.json | 0 .../c/tags/{items => item}/dyes/brown.json | 0 .../c/tags/{items => item}/dyes/cyan.json | 0 .../c/tags/{items => item}/dyes/gray.json | 0 .../c/tags/{items => item}/dyes/green.json | 0 .../tags/{items => item}/dyes/light_blue.json | 0 .../tags/{items => item}/dyes/light_gray.json | 0 .../c/tags/{items => item}/dyes/lime.json | 0 .../c/tags/{items => item}/dyes/magenta.json | 0 .../c/tags/{items => item}/dyes/orange.json | 0 .../c/tags/{items => item}/dyes/pink.json | 0 .../c/tags/{items => item}/dyes/purple.json | 0 .../data/c/tags/{items => item}/dyes/red.json | 0 .../c/tags/{items => item}/dyes/white.json | 0 .../c/tags/{items => item}/dyes/yellow.json | 0 .../data/c/tags/{items => item}/eggs.json | 0 .../data/c/tags/{items => item}/gems.json | 0 .../c/tags/{items => item}/gems/diamond.json | 0 .../c/tags/{items => item}/gems/emerald.json | 0 .../data/c/tags/{items => item}/ingots.json | 0 .../c/tags/{items => item}/ingots/iron.json | 0 .../data/c/tags/{items => item}/nuggets.json | 0 .../c/tags/{items => item}/nuggets/gold.json | 0 .../c/tags/{items => item}/nuggets/iron.json | 0 .../data/c/tags/{items => item}/ores.json | 0 .../c/tags/{items => item}/rods/wooden.json | 0 .../data/c/tags/{items => item}/stones.json | 0 gradle.properties | 10 +-- .../data/c/tags/{items => item}/eggs.json | 0 .../data/c/tags/{items => item}/nuggets.json | 0 .../c/tags/{items => item}/nuggets/gold.json | 0 .../c/tags/{items => item}/nuggets/iron.json | 0 .../data/c/tags/{items => item}/stones.json | 0 settings.gradle | 4 +- 63 files changed, 157 insertions(+), 170 deletions(-) create mode 100644 common/src/main/java/net/blay09/mods/balm/mixin/ModelBakeryAccessor.java rename fabric/src/main/resources/data/c/tags/{items => item}/eggs.json (100%) rename fabric/src/main/resources/data/c/tags/{items => item}/nuggets.json (100%) rename fabric/src/main/resources/data/c/tags/{items => item}/nuggets/gold.json (100%) rename fabric/src/main/resources/data/c/tags/{items => item}/nuggets/iron.json (100%) rename fabric/src/main/resources/data/c/tags/{items => item}/stones.json (100%) rename forge/src/main/resources/data/c/tags/{items => item}/chests/wooden.json (100%) rename forge/src/main/resources/data/c/tags/{items => item}/cooking_oil.json (100%) rename forge/src/main/resources/data/c/tags/{items => item}/dyes.json (100%) rename forge/src/main/resources/data/c/tags/{items => item}/dyes/black.json (100%) rename forge/src/main/resources/data/c/tags/{items => item}/dyes/blue.json (100%) rename forge/src/main/resources/data/c/tags/{items => item}/dyes/brown.json (100%) rename forge/src/main/resources/data/c/tags/{items => item}/dyes/cyan.json (100%) rename forge/src/main/resources/data/c/tags/{items => item}/dyes/gray.json (100%) rename forge/src/main/resources/data/c/tags/{items => item}/dyes/green.json (100%) rename forge/src/main/resources/data/c/tags/{items => item}/dyes/light_blue.json (100%) rename forge/src/main/resources/data/c/tags/{items => item}/dyes/light_gray.json (100%) rename forge/src/main/resources/data/c/tags/{items => item}/dyes/lime.json (100%) rename forge/src/main/resources/data/c/tags/{items => item}/dyes/magenta.json (100%) rename forge/src/main/resources/data/c/tags/{items => item}/dyes/orange.json (100%) rename forge/src/main/resources/data/c/tags/{items => item}/dyes/pink.json (100%) rename forge/src/main/resources/data/c/tags/{items => item}/dyes/purple.json (100%) rename forge/src/main/resources/data/c/tags/{items => item}/dyes/red.json (100%) rename forge/src/main/resources/data/c/tags/{items => item}/dyes/white.json (100%) rename forge/src/main/resources/data/c/tags/{items => item}/dyes/yellow.json (100%) rename forge/src/main/resources/data/c/tags/{items => item}/eggs.json (100%) rename forge/src/main/resources/data/c/tags/{items => item}/gems.json (100%) rename forge/src/main/resources/data/c/tags/{items => item}/gems/diamond.json (100%) rename forge/src/main/resources/data/c/tags/{items => item}/gems/emerald.json (100%) rename forge/src/main/resources/data/c/tags/{items => item}/ingots.json (100%) rename forge/src/main/resources/data/c/tags/{items => item}/ingots/iron.json (100%) rename forge/src/main/resources/data/c/tags/{items => item}/nuggets.json (100%) rename forge/src/main/resources/data/c/tags/{items => item}/nuggets/gold.json (100%) rename forge/src/main/resources/data/c/tags/{items => item}/nuggets/iron.json (100%) rename forge/src/main/resources/data/c/tags/{items => item}/ores.json (100%) rename forge/src/main/resources/data/c/tags/{items => item}/rods/wooden.json (100%) rename forge/src/main/resources/data/c/tags/{items => item}/stones.json (100%) rename neoforge/src/main/resources/data/c/tags/{items => item}/eggs.json (100%) rename neoforge/src/main/resources/data/c/tags/{items => item}/nuggets.json (100%) rename neoforge/src/main/resources/data/c/tags/{items => item}/nuggets/gold.json (100%) rename neoforge/src/main/resources/data/c/tags/{items => item}/nuggets/iron.json (100%) rename neoforge/src/main/resources/data/c/tags/{items => item}/stones.json (100%) diff --git a/.gitignore b/.gitignore index 09cd281f..2bd8cedb 100644 --- a/.gitignore +++ b/.gitignore @@ -30,4 +30,4 @@ bin/ # fabric -run/ +runs/ diff --git a/buildSrc/src/main/groovy/multiloader-common.gradle b/buildSrc/src/main/groovy/multiloader-common.gradle index 2978544e..652a7023 100644 --- a/buildSrc/src/main/groovy/multiloader-common.gradle +++ b/buildSrc/src/main/groovy/multiloader-common.gradle @@ -51,6 +51,13 @@ sourcesJar { } } +tasks.withType(Javadoc).tap { + configureEach { + failOnError false + options.addStringOption('Xdoclint:-missing', '-quiet') + } +} + jar { from(rootProject.file("LICENSE")) { rename { "${it}_${mod_name}" } diff --git a/common/build.gradle b/common/build.gradle index 83aaab67..f0d5fe89 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -51,35 +51,6 @@ artifacts { commonGeneratedResources sourceSets.generated.resources.sourceDirectories.singleFile } -/*publishing { - publications { - mavenJava(MavenPublication) { - artifactId = mod_id + "-common" - version = project.version + (!project.version.endsWith("SNAPSHOT") ? "+" + minecraft_version : "") - - artifact jar - - artifact sourcesJar { - archiveClassifier = 'sources' - } - - artifact project.javadocJar { - archiveClassifier = 'javadoc' - } - } - } - - repositories { - maven { - var releasesRepoUrl = "https://maven.twelveiterations.com/repository/maven-releases/" - var snapshotsRepoUrl = "https://maven.twelveiterations.com/repository/maven-snapshots/" - url = uri(version.toString().endsWith("SNAPSHOT") ? snapshotsRepoUrl : releasesRepoUrl) - name = "twelveIterationsNexus" - credentials(PasswordCredentials) - } - } -}*/ - sourceSets { main { java { diff --git a/common/src/main/java/net/blay09/mods/balm/api/DeferredObject.java b/common/src/main/java/net/blay09/mods/balm/api/DeferredObject.java index 8b5d34c1..8bc975fb 100644 --- a/common/src/main/java/net/blay09/mods/balm/api/DeferredObject.java +++ b/common/src/main/java/net/blay09/mods/balm/api/DeferredObject.java @@ -5,21 +5,21 @@ import java.util.function.Supplier; public class DeferredObject { - private final ResourceLocation identifier; + private final ResourceLocation id; private final Supplier supplier; private final Supplier canResolveFunc; protected T object; - protected DeferredObject(ResourceLocation identifier) { - this(identifier, () -> null, () -> false); + protected DeferredObject(ResourceLocation id) { + this(id, () -> null, () -> false); } - public DeferredObject(ResourceLocation identifier, Supplier supplier) { - this(identifier, supplier, () -> false); + public DeferredObject(ResourceLocation id, Supplier supplier) { + this(id, supplier, () -> false); } - public DeferredObject(ResourceLocation identifier, Supplier supplier, Supplier canResolveFunc) { - this.identifier = identifier; + public DeferredObject(ResourceLocation id, Supplier supplier, Supplier canResolveFunc) { + this.id = id; this.supplier = supplier; this.canResolveFunc = canResolveFunc; } @@ -57,7 +57,7 @@ public DeferredObject resolveImmediately() { } public ResourceLocation getIdentifier() { - return identifier; + return id; } public static DeferredObject of(ResourceLocation identifier, T instance) { diff --git a/common/src/main/java/net/blay09/mods/balm/api/client/rendering/BalmModels.java b/common/src/main/java/net/blay09/mods/balm/api/client/rendering/BalmModels.java index 38b43a66..f14d58ae 100644 --- a/common/src/main/java/net/blay09/mods/balm/api/client/rendering/BalmModels.java +++ b/common/src/main/java/net/blay09/mods/balm/api/client/rendering/BalmModels.java @@ -7,7 +7,6 @@ import net.minecraft.client.renderer.block.model.BlockModel; import net.minecraft.client.renderer.block.model.ItemTransforms; import net.minecraft.client.renderer.texture.TextureAtlas; -import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.resources.model.*; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.level.block.Block; @@ -17,22 +16,21 @@ import java.util.*; import java.util.function.BiConsumer; -import java.util.function.BiFunction; import java.util.function.Function; import java.util.function.Supplier; public interface BalmModels { - DeferredObject loadModel(ResourceLocation identifier); + DeferredObject loadModel(ModelResourceLocation identifier); - DeferredObject bakeModel(ResourceLocation identifier, UnbakedModel model); + DeferredObject bakeModel(ModelResourceLocation identifier, UnbakedModel model); - default DeferredObject loadDynamicModel(ResourceLocation identifier, Set models, @Nullable Function modelFunction, @Nullable Function> textureMapFunction, @Nullable BiConsumer transformFunction) { + default DeferredObject loadDynamicModel(ModelResourceLocation identifier, Set models, @Nullable Function modelFunction, @Nullable Function> textureMapFunction, @Nullable BiConsumer transformFunction) { return loadDynamicModel(identifier, models, modelFunction, textureMapFunction, transformFunction, Collections.emptyList()); } - DeferredObject loadDynamicModel(ResourceLocation identifier, Set models, @Nullable Function modelFunction, @Nullable Function> textureMapFunction, @Nullable BiConsumer transformFunction, List renderTypes); + DeferredObject loadDynamicModel(ModelResourceLocation identifier, Set models, @Nullable Function modelFunction, @Nullable Function> textureMapFunction, @Nullable BiConsumer transformFunction, List renderTypes); - DeferredObject retexture(ResourceLocation identifier, Map textureMap); + DeferredObject retexture(ModelResourceLocation identifier, Map textureMap); void overrideModel(Supplier block, Supplier model); @@ -42,13 +40,13 @@ default DeferredObject loadDynamicModel(ResourceLocation identifier, UnbakedModel getUnbakedMissingModel(); - default UnbakedModel retexture(ModelBakery bakery, ResourceLocation identifier, Map textureMap) { + default UnbakedModel retexture(ModelBakery bakery, ModelResourceLocation identifier, Map textureMap) { Map> replacedTexturesMapped = new HashMap<>(); for (Map.Entry entry : textureMap.entrySet()) { - replacedTexturesMapped.put(entry.getKey(), Either.left(new Material(TextureAtlas.LOCATION_BLOCKS, new ResourceLocation(entry.getValue())))); + replacedTexturesMapped.put(entry.getKey(), Either.left(new Material(TextureAtlas.LOCATION_BLOCKS, ResourceLocation.parse(entry.getValue())))); } - BlockModel blockModel = new BlockModel(identifier, + BlockModel blockModel = new BlockModel(identifier.id(), Collections.emptyList(), replacedTexturesMapped, false, @@ -57,10 +55,10 @@ default UnbakedModel retexture(ModelBakery bakery, ResourceLocation identifier, Collections.emptyList()); // We have to resolve parents as that is usually done during stitching, which we're already past - blockModel.resolveParents(bakery::getModel); + // TODO 1.21 blockModel.resolveParents(bakery::getModel); return blockModel; } - ModelBaker createBaker(ResourceLocation location, BiFunction spriteBiFunction); + ModelBaker createBaker(ModelResourceLocation location, ModelBakery.TextureGetter textureGetter); } diff --git a/common/src/main/java/net/blay09/mods/balm/api/tag/BalmItemTags.java b/common/src/main/java/net/blay09/mods/balm/api/tag/BalmItemTags.java index f67c4986..eb36d273 100644 --- a/common/src/main/java/net/blay09/mods/balm/api/tag/BalmItemTags.java +++ b/common/src/main/java/net/blay09/mods/balm/api/tag/BalmItemTags.java @@ -7,39 +7,39 @@ import net.minecraft.world.item.Item; public class BalmItemTags { - public static final TagKey COOKING_OIL = TagKey.create(Registries.ITEM, new ResourceLocation("c", "cooking_oil")); - public static final TagKey DIAMONDS = TagKey.create(Registries.ITEM, new ResourceLocation("c", "gems/diamond")); - public static final TagKey EGGS = TagKey.create(Registries.ITEM, new ResourceLocation("c", "eggs")); - public static final TagKey EMERALDS = TagKey.create(Registries.ITEM, new ResourceLocation("c", "gems/emerald")); - public static final TagKey GEMS = TagKey.create(Registries.ITEM, new ResourceLocation("c", "gems")); - public static final TagKey GOLD_NUGGETS = TagKey.create(Registries.ITEM, new ResourceLocation("c", "nuggets/gold")); - public static final TagKey INGOTS = TagKey.create(Registries.ITEM, new ResourceLocation("c", "ingots")); - public static final TagKey IRON_INGOTS = TagKey.create(Registries.ITEM, new ResourceLocation("c", "ingots/iron")); - public static final TagKey IRON_NUGGETS = TagKey.create(Registries.ITEM, new ResourceLocation("c", "nuggets/iron")); - public static final TagKey NUGGETS = TagKey.create(Registries.ITEM, new ResourceLocation("c", "nuggets")); - public static final TagKey ORES = TagKey.create(Registries.ITEM, new ResourceLocation("c", "ores")); - public static final TagKey STONES = TagKey.create(Registries.ITEM, new ResourceLocation("c", "stones")); - public static final TagKey WOODEN_CHESTS = TagKey.create(Registries.ITEM, new ResourceLocation("c", "chests/wooden")); - public static final TagKey WOODEN_RODS = TagKey.create(Registries.ITEM, new ResourceLocation("c", "rods/wooden")); + public static final TagKey COOKING_OIL = TagKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath("c", "cooking_oil")); + public static final TagKey DIAMONDS = TagKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath("c", "gems/diamond")); + public static final TagKey EGGS = TagKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath("c", "eggs")); + public static final TagKey EMERALDS = TagKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath("c", "gems/emerald")); + public static final TagKey GEMS = TagKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath("c", "gems")); + public static final TagKey GOLD_NUGGETS = TagKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath("c", "nuggets/gold")); + public static final TagKey INGOTS = TagKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath("c", "ingots")); + public static final TagKey IRON_INGOTS = TagKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath("c", "ingots/iron")); + public static final TagKey IRON_NUGGETS = TagKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath("c", "nuggets/iron")); + public static final TagKey NUGGETS = TagKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath("c", "nuggets")); + public static final TagKey ORES = TagKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath("c", "ores")); + public static final TagKey STONES = TagKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath("c", "stones")); + public static final TagKey WOODEN_CHESTS = TagKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath("c", "chests/wooden")); + public static final TagKey WOODEN_RODS = TagKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath("c", "rods/wooden")); // Dye tags - public static final TagKey DYES = TagKey.create(Registries.ITEM, new ResourceLocation("c", "dyes")); - public static final TagKey WHITE_DYES = TagKey.create(Registries.ITEM, new ResourceLocation("c", "dyes/white")); - public static final TagKey ORANGE_DYES = TagKey.create(Registries.ITEM, new ResourceLocation("c", "dyes/orange")); - public static final TagKey MAGENTA_DYES = TagKey.create(Registries.ITEM, new ResourceLocation("c", "dyes/magenta")); - public static final TagKey LIGHT_BLUE_DYES = TagKey.create(Registries.ITEM, new ResourceLocation("c", "dyes/light_blue")); - public static final TagKey YELLOW_DYES = TagKey.create(Registries.ITEM, new ResourceLocation("c", "dyes/yellow")); - public static final TagKey LIME_DYES = TagKey.create(Registries.ITEM, new ResourceLocation("c", "dyes/lime")); - public static final TagKey PINK_DYES = TagKey.create(Registries.ITEM, new ResourceLocation("c", "dyes/pink")); - public static final TagKey GRAY_DYES = TagKey.create(Registries.ITEM, new ResourceLocation("c", "dyes/gray")); - public static final TagKey LIGHT_GRAY_DYES = TagKey.create(Registries.ITEM, new ResourceLocation("c", "dyes/light_gray")); - public static final TagKey CYAN_DYES = TagKey.create(Registries.ITEM, new ResourceLocation("c", "dyes/cyan")); - public static final TagKey PURPLE_DYES = TagKey.create(Registries.ITEM, new ResourceLocation("c", "dyes/purple")); - public static final TagKey BLUE_DYES = TagKey.create(Registries.ITEM, new ResourceLocation("c", "dyes/blue")); - public static final TagKey BROWN_DYES = TagKey.create(Registries.ITEM, new ResourceLocation("c", "dyes/brown")); - public static final TagKey GREEN_DYES = TagKey.create(Registries.ITEM, new ResourceLocation("c", "dyes/green")); - public static final TagKey RED_DYES = TagKey.create(Registries.ITEM, new ResourceLocation("c", "dyes/red")); - public static final TagKey BLACK_DYES = TagKey.create(Registries.ITEM, new ResourceLocation("c", "dyes/black")); + public static final TagKey DYES = TagKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath("c", "dyes")); + public static final TagKey WHITE_DYES = TagKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath("c", "dyes/white")); + public static final TagKey ORANGE_DYES = TagKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath("c", "dyes/orange")); + public static final TagKey MAGENTA_DYES = TagKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath("c", "dyes/magenta")); + public static final TagKey LIGHT_BLUE_DYES = TagKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath("c", "dyes/light_blue")); + public static final TagKey YELLOW_DYES = TagKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath("c", "dyes/yellow")); + public static final TagKey LIME_DYES = TagKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath("c", "dyes/lime")); + public static final TagKey PINK_DYES = TagKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath("c", "dyes/pink")); + public static final TagKey GRAY_DYES = TagKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath("c", "dyes/gray")); + public static final TagKey LIGHT_GRAY_DYES = TagKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath("c", "dyes/light_gray")); + public static final TagKey CYAN_DYES = TagKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath("c", "dyes/cyan")); + public static final TagKey PURPLE_DYES = TagKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath("c", "dyes/purple")); + public static final TagKey BLUE_DYES = TagKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath("c", "dyes/blue")); + public static final TagKey BROWN_DYES = TagKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath("c", "dyes/brown")); + public static final TagKey GREEN_DYES = TagKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath("c", "dyes/green")); + public static final TagKey RED_DYES = TagKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath("c", "dyes/red")); + public static final TagKey BLACK_DYES = TagKey.create(Registries.ITEM, ResourceLocation.fromNamespaceAndPath("c", "dyes/black")); @SuppressWarnings("unchecked") public static final TagKey[] DYE_TAGS = new TagKey[] { diff --git a/common/src/main/java/net/blay09/mods/balm/common/client/rendering/AbstractCachedDynamicModel.java b/common/src/main/java/net/blay09/mods/balm/common/client/rendering/AbstractCachedDynamicModel.java index 289ce5da..34b2a858 100644 --- a/common/src/main/java/net/blay09/mods/balm/common/client/rendering/AbstractCachedDynamicModel.java +++ b/common/src/main/java/net/blay09/mods/balm/common/client/rendering/AbstractCachedDynamicModel.java @@ -30,20 +30,21 @@ public abstract class AbstractCachedDynamicModel implements BakedModel { private final Map cache = new HashMap<>(); - private final Map baseModelCache = new HashMap<>(); - private final Map unbakedModels = new HashMap<>(); + private final Map baseModelCache = new HashMap<>(); + private final Map unbakedModels = new HashMap<>(); private final ModelBakery modelBakery; - private final Function modelResolver; - private final Function baseModelFunction; + private final Function modelResolver; + private final Function baseModelFunction; private final List, BakedModel>> parts; private final Function> textureMapFunction; private final BiConsumer transformFunction; - private final ResourceLocation location; + private final ModelResourceLocation location; + private final ModelBakery.TextureGetter textureGetter; private TextureAtlasSprite particleTexture; - public AbstractCachedDynamicModel(ModelBakery modelBakery, Map models, Function baseModelFunction, @Nullable List, BakedModel>> parts, @Nullable Function> textureMapFunction, @Nullable BiConsumer transformFunction, List renderTypes, ResourceLocation location) { + public AbstractCachedDynamicModel(ModelBakery modelBakery, Map models, Function baseModelFunction, @Nullable List, BakedModel>> parts, @Nullable Function> textureMapFunction, @Nullable BiConsumer transformFunction, List renderTypes, ModelResourceLocation location, ModelBakery.TextureGetter textureGetter) { this.modelBakery = modelBakery; unbakedModels.putAll(models); this.modelResolver = unbakedModels::get; @@ -52,6 +53,7 @@ public AbstractCachedDynamicModel(ModelBakery modelBakery, Map getQuads(@Nullable BlockState state, @Nullable Direction BalmModels models = BalmClient.getModels(); ModelState modelTransform = models.getModelState(new Transformation(transform)); - ResourceLocation baseModelLocation = baseModelFunction.apply(state); + ModelResourceLocation baseModelLocation = baseModelFunction.apply(state); // If we're going to retexture, we need to ensure the base model has already been baked to prevent circular parent references in the retextured model if (textureMapFunction != null && !baseModelCache.containsKey(baseModelLocation)) { final UnbakedModel baseModel = modelResolver.apply(baseModelLocation); - final BakedModel bakedBaseModel = baseModel.bake(models.createBaker(baseModelLocation, this::getSprite), + final BakedModel bakedBaseModel = baseModel.bake(models.createBaker(baseModelLocation, textureGetter), Material::sprite, - modelTransform, - baseModelLocation); + modelTransform); baseModelCache.put(baseModelLocation, bakedBaseModel); } UnbakedModel retexturedBaseModel = textureMapFunction != null ? models.retexture(modelBakery, baseModelLocation, textureMapFunction.apply(state)) : modelResolver.apply(baseModelLocation); - bakedModel = retexturedBaseModel.bake(models.createBaker(location, this::getSprite), Material::sprite, modelTransform, location); + bakedModel = retexturedBaseModel.bake(models.createBaker(location, textureGetter), Material::sprite, modelTransform); cache.put(stateString, bakedModel); if (particleTexture == null && bakedModel != null) { @@ -138,7 +139,4 @@ public ItemOverrides getOverrides() { public abstract List getBlockRenderTypes(BlockState state, RandomSource rand); public abstract List getItemRenderTypes(ItemStack itemStack, boolean fabulous); - private TextureAtlasSprite getSprite(ResourceLocation modelLocation, Material material) { - return material.sprite(); - } } diff --git a/common/src/main/java/net/blay09/mods/balm/config/ExampleConfigData.java b/common/src/main/java/net/blay09/mods/balm/config/ExampleConfigData.java index f8893a29..851017c8 100644 --- a/common/src/main/java/net/blay09/mods/balm/config/ExampleConfigData.java +++ b/common/src/main/java/net/blay09/mods/balm/config/ExampleConfigData.java @@ -32,7 +32,7 @@ public enum ExampleEnum { @Synced @ExpectedType(ResourceLocation.class) @Comment("This is an example resource location set property") - public Set exampleResourceLocationSet = Set.of(new ResourceLocation("dirt"), new ResourceLocation("diamond")); + public Set exampleResourceLocationSet = Set.of(ResourceLocation.withDefaultNamespace("dirt"), ResourceLocation.withDefaultNamespace("diamond")); @ExpectedType(Integer.class) @Comment("This is an example int list property") public List exampleIntList = Arrays.asList(12, 24); diff --git a/common/src/main/java/net/blay09/mods/balm/mixin/ModelBakeryAccessor.java b/common/src/main/java/net/blay09/mods/balm/mixin/ModelBakeryAccessor.java new file mode 100644 index 00000000..92e2d15d --- /dev/null +++ b/common/src/main/java/net/blay09/mods/balm/mixin/ModelBakeryAccessor.java @@ -0,0 +1,13 @@ +package net.blay09.mods.balm.mixin; + +import net.minecraft.client.resources.model.ModelBakery; +import net.minecraft.client.resources.model.UnbakedModel; +import net.minecraft.resources.ResourceLocation; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Invoker; + +@Mixin(ModelBakery.class) +public interface ModelBakeryAccessor { + @Invoker + UnbakedModel callGetModel(ResourceLocation location); +} diff --git a/common/src/main/resources/balm.mixins.json b/common/src/main/resources/balm.mixins.json index 1874d57a..28dcee39 100644 --- a/common/src/main/resources/balm.mixins.json +++ b/common/src/main/resources/balm.mixins.json @@ -7,6 +7,7 @@ "mixins": [ ], "client": [ + "ModelBakeryAccessor" ], "server": [ ], diff --git a/fabric/src/main/java/net/blay09/mods/balm/fabric/FabricBalm.java b/fabric/src/main/java/net/blay09/mods/balm/fabric/FabricBalm.java index 810ea5ff..530a3211 100644 --- a/fabric/src/main/java/net/blay09/mods/balm/fabric/FabricBalm.java +++ b/fabric/src/main/java/net/blay09/mods/balm/fabric/FabricBalm.java @@ -34,8 +34,8 @@ public void onInitialize() { }); var providers = ((FabricBalmProviders) Balm.getProviders()); - providers.registerProvider(new ResourceLocation("balm", "container"), Container.class); - providers.registerProvider(new ResourceLocation("balm", "fluid_tank"), FluidTank.class); + providers.registerProvider(ResourceLocation.fromNamespaceAndPath("balm", "container"), Container.class); + providers.registerProvider(ResourceLocation.fromNamespaceAndPath("balm", "fluid_tank"), FluidTank.class); ItemStorage.SIDED.registerFallback((world, pos, state, blockEntity, direction) -> { if (blockEntity instanceof BalmContainerProvider containerProvider) { diff --git a/fabric/src/main/java/net/blay09/mods/balm/fabric/FabricBalmRegistries.java b/fabric/src/main/java/net/blay09/mods/balm/fabric/FabricBalmRegistries.java index dfc8a30c..7996943f 100644 --- a/fabric/src/main/java/net/blay09/mods/balm/fabric/FabricBalmRegistries.java +++ b/fabric/src/main/java/net/blay09/mods/balm/fabric/FabricBalmRegistries.java @@ -72,7 +72,7 @@ public TagKey getItemTag(ResourceLocation key) { @Override public void enableMilkFluid() { - milkFluid = Registry.register(BuiltInRegistries.FLUID, new ResourceLocation("balm-fabric", "milk"), new SimpleMilkFluid()); + milkFluid = Registry.register(BuiltInRegistries.FLUID, ResourceLocation.fromNamespaceAndPath("balm-fabric", "milk"), new SimpleMilkFluid()); } @Override diff --git a/fabric/src/main/java/net/blay09/mods/balm/fabric/client/FabricBalmClient.java b/fabric/src/main/java/net/blay09/mods/balm/fabric/client/FabricBalmClient.java index 866181fb..a6963e63 100644 --- a/fabric/src/main/java/net/blay09/mods/balm/fabric/client/FabricBalmClient.java +++ b/fabric/src/main/java/net/blay09/mods/balm/fabric/client/FabricBalmClient.java @@ -7,7 +7,7 @@ import net.blay09.mods.balm.fabric.network.FabricBalmNetworking; import net.fabricmc.api.ClientModInitializer; import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents; -import net.fabricmc.fabric.api.client.model.loading.v1.ModelLoadingPlugin; +// TODO 1.21 import net.fabricmc.fabric.api.client.model.loading.v1.ModelLoadingPlugin; public class FabricBalmClient implements ClientModInitializer { @Override @@ -15,7 +15,7 @@ public void onInitializeClient() { ClientLifecycleEvents.CLIENT_STARTED.register(client -> FabricBalmNetworking.initializeClientHandlers()); Balm.getEvents().onEvent(DisconnectedFromServerEvent.class, event -> Balm.getConfig().resetToBackingConfigs()); - - ModelLoadingPlugin.register((FabricBalmModels) BalmClient.getModels()); + + // TODO 1.21 ModelLoadingPlugin.register((FabricBalmModels) BalmClient.getModels()); } } diff --git a/fabric/src/main/java/net/blay09/mods/balm/fabric/client/rendering/FabricBalmModels.java b/fabric/src/main/java/net/blay09/mods/balm/fabric/client/rendering/FabricBalmModels.java index 8d2138f0..e11fe21c 100644 --- a/fabric/src/main/java/net/blay09/mods/balm/fabric/client/rendering/FabricBalmModels.java +++ b/fabric/src/main/java/net/blay09/mods/balm/fabric/client/rendering/FabricBalmModels.java @@ -4,7 +4,8 @@ import com.mojang.math.Transformation; import net.blay09.mods.balm.api.DeferredObject; import net.blay09.mods.balm.api.client.rendering.BalmModels; -import net.fabricmc.fabric.api.client.model.loading.v1.ModelLoadingPlugin; +// TODO 1.21 import net.fabricmc.fabric.api.client.model.loading.v1.ModelLoadingPlugin; +import net.blay09.mods.balm.mixin.ModelBakeryAccessor; import net.fabricmc.loader.api.FabricLoader; import net.fabricmc.loader.api.MappingResolver; import net.minecraft.client.renderer.RenderType; @@ -21,18 +22,17 @@ import java.lang.reflect.InvocationTargetException; import java.util.*; import java.util.function.BiConsumer; -import java.util.function.BiFunction; import java.util.function.Function; import java.util.function.Supplier; -public class FabricBalmModels implements BalmModels, ModelLoadingPlugin { +public class FabricBalmModels implements BalmModels { // TODO 1.21 , ModelLoadingPlugin { private static abstract class DeferredModel extends DeferredObject { - public DeferredModel(ResourceLocation identifier) { - super(identifier); + public DeferredModel(ModelResourceLocation identifier) { + super(identifier.id()); } - public abstract BakedModel resolve(ModelBakery modelBakery, BiFunction spriteBiFunction); + public abstract BakedModel resolve(ModelBakery modelBakery, ModelBakery.TextureGetter textureGetter); @Override public void set(BakedModel object) { @@ -40,22 +40,22 @@ public void set(BakedModel object) { } } - private final List additionalModels = Collections.synchronizedList(new ArrayList<>()); + private final List additionalModels = Collections.synchronizedList(new ArrayList<>()); private final List modelsToBake = Collections.synchronizedList(new ArrayList<>()); public final List, Supplier>> overrides = Collections.synchronizedList(new ArrayList<>()); private ModelBakery modelBakery; - @Override - public void onInitializeModelLoader(Context context) { - context.addModels(additionalModels); - } + // TODO 1.21 @Override + // TODO 1.21 public void onInitializeModelLoader(Context context) { + // TODO 1.21 context.addModels(additionalModels); + // TODO 1.21 } - public void onBakeModels(ModelBakery modelBakery, BiFunction spriteBiFunction) { + public void onBakeModels(ModelBakery modelBakery, ModelBakery.TextureGetter textureGetter) { this.modelBakery = modelBakery; synchronized (modelsToBake) { for (DeferredModel model : modelsToBake) { - model.set(model.resolve(modelBakery, spriteBiFunction)); + model.set(model.resolve(modelBakery, textureGetter)); } } @@ -72,10 +72,10 @@ public void onBakeModels(ModelBakery modelBakery, BiFunction loadModel(final ResourceLocation identifier) { + public DeferredObject loadModel(final ModelResourceLocation identifier) { DeferredModel deferredModel = new DeferredModel(identifier) { @Override - public BakedModel resolve(ModelBakery modelBakery, BiFunction spriteBiFunction) { + public BakedModel resolve(ModelBakery modelBakery, ModelBakery.TextureGetter textureGetter) { return resolve(); } @@ -94,13 +94,13 @@ public boolean canResolve() { } @Override - public DeferredObject bakeModel(ResourceLocation identifier, UnbakedModel model) { + public DeferredObject bakeModel(ModelResourceLocation identifier, UnbakedModel model) { DeferredModel deferredModel = new DeferredModel(identifier) { @Override - public BakedModel resolve(ModelBakery bakery, BiFunction spriteBiFunction) { - ModelBaker baker = createBaker(identifier, spriteBiFunction); - Function modelTextureGetter = createModelTextureGetter(identifier, spriteBiFunction); - return model.bake(baker, modelTextureGetter, getModelState(Transformation.identity()), identifier); + public BakedModel resolve(ModelBakery bakery, ModelBakery.TextureGetter textureGetter) { + ModelBaker baker = createBaker(identifier, textureGetter); + Function modelTextureGetter = createModelTextureGetter(identifier, textureGetter); + return model.bake(baker, modelTextureGetter, getModelState(Transformation.identity())); } }; modelsToBake.add(deferredModel); @@ -108,16 +108,16 @@ public BakedModel resolve(ModelBakery bakery, BiFunction loadDynamicModel(ResourceLocation identifier, Set models, @Nullable Function modelFunction, @Nullable Function> textureMapFunction, @Nullable BiConsumer transformFunction, List renderTypes) { - Function effectiveModelFunction = modelFunction != null ? modelFunction : (it -> identifier); + public DeferredObject loadDynamicModel(ModelResourceLocation identifier, Set models, @Nullable Function modelFunction, @Nullable Function> textureMapFunction, @Nullable BiConsumer transformFunction, List renderTypes) { + Function effectiveModelFunction = modelFunction != null ? modelFunction : (it -> identifier); DeferredModel deferredModel = new DeferredModel(identifier) { @Override - public BakedModel resolve(ModelBakery bakery, BiFunction spriteBiFunction) { - final var unbakedModels = new HashMap(); + public BakedModel resolve(ModelBakery bakery, ModelBakery.TextureGetter textureGetter) { + final var unbakedModels = new HashMap(); for (final var modelId : models) { - unbakedModels.put(modelId, bakery.getModel(modelId)); + unbakedModels.put(modelId, ((ModelBakeryAccessor) bakery).callGetModel(modelId.id())); } - return new FabricCachedDynamicModel(bakery, unbakedModels, effectiveModelFunction, null, textureMapFunction, transformFunction, renderTypes, identifier); + return new FabricCachedDynamicModel(bakery, unbakedModels, effectiveModelFunction, null, textureMapFunction, transformFunction, renderTypes, identifier, textureGetter); } }; modelsToBake.add(deferredModel); @@ -125,14 +125,14 @@ public BakedModel resolve(ModelBakery bakery, BiFunction retexture(ResourceLocation identifier, Map textureMap) { + public DeferredObject retexture(ModelResourceLocation identifier, Map textureMap) { DeferredModel deferredModel = new DeferredModel(identifier) { @Override - public BakedModel resolve(ModelBakery bakery, BiFunction spriteBiFunction) { + public BakedModel resolve(ModelBakery bakery, ModelBakery.TextureGetter textureGetter) { UnbakedModel model = retexture(bakery, identifier, textureMap); - ModelBaker baker = createBaker(identifier, spriteBiFunction); - Function modelTextureGetter = createModelTextureGetter(identifier, spriteBiFunction); - return model.bake(baker, modelTextureGetter, getModelState(Transformation.identity()), identifier); + ModelBaker baker = createBaker(identifier, textureGetter); + Function modelTextureGetter = createModelTextureGetter(identifier, textureGetter); + return model.bake(baker, modelTextureGetter, getModelState(Transformation.identity())); } }; modelsToBake.add(deferredModel); @@ -151,28 +151,28 @@ public ModelState getModelState(Transformation transformation) { @Override public UnbakedModel getUnbakedModelOrMissing(ResourceLocation location) { - return modelBakery.getModel(location); + return ((ModelBakeryAccessor) modelBakery).callGetModel(location); } @Override public UnbakedModel getUnbakedMissingModel() { - return modelBakery.getModel(ModelBakery.MISSING_MODEL_LOCATION); + return ((ModelBakeryAccessor) modelBakery).callGetModel(ModelBakery.MISSING_MODEL_LOCATION); } @Override - public ModelBaker createBaker(ResourceLocation location, BiFunction spriteBiFunction) { + public ModelBaker createBaker(ModelResourceLocation location, ModelBakery.TextureGetter textureGetter) { try { MappingResolver mappings = FabricLoader.getInstance().getMappingResolver(); Class clazz = Class.forName(mappings.mapClassName("intermediary", "net.minecraft.class_1088$class_7778")); - Constructor constructor = clazz.getDeclaredConstructor(ModelBakery.class, BiFunction.class, ResourceLocation.class); + Constructor constructor = clazz.getDeclaredConstructor(ModelBakery.class, ModelBakery.TextureGetter.class, ModelResourceLocation.class); constructor.setAccessible(true); - return (ModelBaker) constructor.newInstance(modelBakery, spriteBiFunction, location); + return (ModelBaker) constructor.newInstance(modelBakery, textureGetter, location); } catch (ClassNotFoundException | NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e) { throw new RuntimeException("Balm failed to create model baker", e); } } - private Function createModelTextureGetter(ResourceLocation location, BiFunction spriteBiFunction) { - return (Material material) -> (TextureAtlasSprite) spriteBiFunction.apply(location, material); + private Function createModelTextureGetter(ModelResourceLocation location, ModelBakery.TextureGetter textureGetter) { + return (Material material) -> (TextureAtlasSprite) textureGetter.get(location, material); } } diff --git a/fabric/src/main/java/net/blay09/mods/balm/fabric/client/rendering/FabricCachedDynamicModel.java b/fabric/src/main/java/net/blay09/mods/balm/fabric/client/rendering/FabricCachedDynamicModel.java index 05272a5d..630a9a67 100644 --- a/fabric/src/main/java/net/blay09/mods/balm/fabric/client/rendering/FabricCachedDynamicModel.java +++ b/fabric/src/main/java/net/blay09/mods/balm/fabric/client/rendering/FabricCachedDynamicModel.java @@ -4,6 +4,7 @@ import net.minecraft.client.renderer.RenderType; import net.minecraft.client.resources.model.BakedModel; import net.minecraft.client.resources.model.ModelBakery; +import net.minecraft.client.resources.model.ModelResourceLocation; import net.minecraft.client.resources.model.UnbakedModel; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.RandomSource; @@ -20,8 +21,8 @@ import java.util.function.Predicate; public class FabricCachedDynamicModel extends AbstractCachedDynamicModel { - public FabricCachedDynamicModel(ModelBakery modelBakery, Map models, Function baseModelFunction, @Nullable List, BakedModel>> parts, @Nullable Function> textureMapFunction, @Nullable BiConsumer transformFunction, List renderTypes, ResourceLocation location) { - super(modelBakery, models, baseModelFunction, parts, textureMapFunction, transformFunction, renderTypes, location); + public FabricCachedDynamicModel(ModelBakery modelBakery, Map models, Function baseModelFunction, @Nullable List, BakedModel>> parts, @Nullable Function> textureMapFunction, @Nullable BiConsumer transformFunction, List renderTypes, ModelResourceLocation location, ModelBakery.TextureGetter textureGetter) { + super(modelBakery, models, baseModelFunction, parts, textureMapFunction, transformFunction, renderTypes, location, textureGetter); } @Override diff --git a/fabric/src/main/java/net/blay09/mods/balm/fabric/config/FabricConfigLoader.java b/fabric/src/main/java/net/blay09/mods/balm/fabric/config/FabricConfigLoader.java index 92f70351..2ccc7f5f 100644 --- a/fabric/src/main/java/net/blay09/mods/balm/fabric/config/FabricConfigLoader.java +++ b/fabric/src/main/java/net/blay09/mods/balm/fabric/config/FabricConfigLoader.java @@ -181,9 +181,9 @@ private static Object convertValue(Object value, Class type, Class innerTy } } else if (type == ResourceLocation.class) { if (value instanceof String stringValue) { - return new ResourceLocation(stringValue); + return ResourceLocation.parse(stringValue); } else { - return new ResourceLocation(value.toString()); + return ResourceLocation.parse(value.toString()); } } else if (type == Boolean.class || type == Boolean.TYPE) { if (value instanceof Number) { diff --git a/fabric/src/main/java/net/blay09/mods/balm/mixin/GuiMixin.java b/fabric/src/main/java/net/blay09/mods/balm/mixin/GuiMixin.java index 6a41dc02..c39b68f2 100644 --- a/fabric/src/main/java/net/blay09/mods/balm/mixin/GuiMixin.java +++ b/fabric/src/main/java/net/blay09/mods/balm/mixin/GuiMixin.java @@ -2,6 +2,7 @@ import net.blay09.mods.balm.api.Balm; import net.blay09.mods.balm.api.event.client.GuiDrawEvent; +import net.minecraft.client.DeltaTracker; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.GuiGraphics; @@ -19,8 +20,8 @@ public class GuiMixin { @Shadow private Minecraft minecraft; - @Inject(method = "render(Lnet/minecraft/client/gui/GuiGraphics;F)V", at = @At("HEAD"), cancellable = true) - public void renderAllPre(GuiGraphics guiGraphics, float partialTicks, CallbackInfo callbackInfo) { + @Inject(method = "render(Lnet/minecraft/client/gui/GuiGraphics;Lnet/minecraft/client/DeltaTracker;)V", at = @At("HEAD"), cancellable = true) + public void renderAllPre(GuiGraphics guiGraphics, DeltaTracker deltaTracker, CallbackInfo callbackInfo) { GuiDrawEvent.Pre event = new GuiDrawEvent.Pre(minecraft.getWindow(), guiGraphics, GuiDrawEvent.Element.ALL); Balm.getEvents().fireEvent(event); if (event.isCanceled()) { @@ -28,8 +29,8 @@ public void renderAllPre(GuiGraphics guiGraphics, float partialTicks, CallbackIn } } - @Inject(method = "render(Lnet/minecraft/client/gui/GuiGraphics;F)V", at = @At("TAIL")) - public void renderAllPost(GuiGraphics guiGraphics, float partialTicks, CallbackInfo callbackInfo) { + @Inject(method = "render(Lnet/minecraft/client/gui/GuiGraphics;Lnet/minecraft/client/DeltaTracker;)V", at = @At("TAIL")) + public void renderAllPost(GuiGraphics guiGraphics, DeltaTracker deltaTracker, CallbackInfo callbackInfo) { Balm.getEvents().fireEvent(new GuiDrawEvent.Post(minecraft.getWindow(), guiGraphics, GuiDrawEvent.Element.ALL)); } diff --git a/fabric/src/main/java/net/blay09/mods/balm/mixin/ModelBakeryMixin.java b/fabric/src/main/java/net/blay09/mods/balm/mixin/ModelBakeryMixin.java index abe83d8e..f279457d 100644 --- a/fabric/src/main/java/net/blay09/mods/balm/mixin/ModelBakeryMixin.java +++ b/fabric/src/main/java/net/blay09/mods/balm/mixin/ModelBakeryMixin.java @@ -2,21 +2,16 @@ import net.blay09.mods.balm.api.client.BalmClient; import net.blay09.mods.balm.fabric.client.rendering.FabricBalmModels; -import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.client.resources.model.Material; import net.minecraft.client.resources.model.ModelBakery; -import net.minecraft.resources.ResourceLocation; 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; -import java.util.function.BiFunction; - @Mixin(ModelBakery.class) public class ModelBakeryMixin { - @Inject(method = "bakeModels(Ljava/util/function/BiFunction;)V", at = @At("RETURN")) - private void apply(BiFunction spriteBiFunction, CallbackInfo callbackInfo) { - ((FabricBalmModels) BalmClient.getModels()).onBakeModels((ModelBakery) (Object) this, spriteBiFunction); + @Inject(method = "bakeModels(Lnet/minecraft/client/resources/model/ModelBakery$TextureGetter;)V", at = @At("RETURN")) + private void apply(ModelBakery.TextureGetter textureGetter, CallbackInfo callbackInfo) { + ((FabricBalmModels) BalmClient.getModels()).onBakeModels((ModelBakery) (Object) this, textureGetter); } } diff --git a/fabric/src/main/java/net/blay09/mods/balm/mixin/ServerPlayerMixin.java b/fabric/src/main/java/net/blay09/mods/balm/mixin/ServerPlayerMixin.java index c48f4803..2057bbe7 100644 --- a/fabric/src/main/java/net/blay09/mods/balm/mixin/ServerPlayerMixin.java +++ b/fabric/src/main/java/net/blay09/mods/balm/mixin/ServerPlayerMixin.java @@ -5,15 +5,16 @@ import net.blay09.mods.balm.api.event.PlayerOpenMenuEvent; import net.blay09.mods.balm.api.event.TossItemEvent; import net.minecraft.resources.ResourceKey; -import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.MenuProvider; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; +import net.minecraft.world.level.portal.DimensionTransition; import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @@ -23,6 +24,7 @@ @Mixin(ServerPlayer.class) public class ServerPlayerMixin { + @Unique private static final ThreadLocal> fromDimHolder = new ThreadLocal<>(); @Inject(method = "openMenu(Lnet/minecraft/world/MenuProvider;)Ljava/util/OptionalInt;", at = @At("RETURN")) @@ -31,17 +33,17 @@ public void openMenu(@Nullable MenuProvider menuProvider, CallbackInfoReturnable Balm.getEvents().fireEvent(new PlayerOpenMenuEvent(player, player.containerMenu)); } - @Inject(method = "changeDimension(Lnet/minecraft/server/level/ServerLevel;)Lnet/minecraft/world/entity/Entity;", at = @At("HEAD")) - public void changeDimensionHead(ServerLevel level, CallbackInfoReturnable callbackInfo) { + @Inject(method = "changeDimension(Lnet/minecraft/world/level/portal/DimensionTransition;)Lnet/minecraft/world/entity/Entity;", at = @At("HEAD")) + public void changeDimensionHead(DimensionTransition transition, CallbackInfoReturnable callbackInfo) { ServerPlayer player = (ServerPlayer) (Object) this; fromDimHolder.set(player.level().dimension()); } - @Inject(method = "changeDimension(Lnet/minecraft/server/level/ServerLevel;)Lnet/minecraft/world/entity/Entity;", at = @At("RETURN")) - public void changeDimensionTail(ServerLevel level, CallbackInfoReturnable callbackInfo) { + @Inject(method = "changeDimension(Lnet/minecraft/world/level/portal/DimensionTransition;)Lnet/minecraft/world/entity/Entity;", at = @At("RETURN")) + public void changeDimensionTail(DimensionTransition transition, CallbackInfoReturnable callbackInfo) { ServerPlayer player = (ServerPlayer) (Object) this; final ResourceKey fromDim = fromDimHolder.get(); - final ResourceKey toDim = level.dimension(); + final ResourceKey toDim = transition.newLevel().dimension(); Balm.getEvents().fireEvent(new PlayerChangedDimensionEvent(player, fromDim, toDim)); } diff --git a/fabric/src/main/resources/data/c/tags/items/eggs.json b/fabric/src/main/resources/data/c/tags/item/eggs.json similarity index 100% rename from fabric/src/main/resources/data/c/tags/items/eggs.json rename to fabric/src/main/resources/data/c/tags/item/eggs.json diff --git a/fabric/src/main/resources/data/c/tags/items/nuggets.json b/fabric/src/main/resources/data/c/tags/item/nuggets.json similarity index 100% rename from fabric/src/main/resources/data/c/tags/items/nuggets.json rename to fabric/src/main/resources/data/c/tags/item/nuggets.json diff --git a/fabric/src/main/resources/data/c/tags/items/nuggets/gold.json b/fabric/src/main/resources/data/c/tags/item/nuggets/gold.json similarity index 100% rename from fabric/src/main/resources/data/c/tags/items/nuggets/gold.json rename to fabric/src/main/resources/data/c/tags/item/nuggets/gold.json diff --git a/fabric/src/main/resources/data/c/tags/items/nuggets/iron.json b/fabric/src/main/resources/data/c/tags/item/nuggets/iron.json similarity index 100% rename from fabric/src/main/resources/data/c/tags/items/nuggets/iron.json rename to fabric/src/main/resources/data/c/tags/item/nuggets/iron.json diff --git a/fabric/src/main/resources/data/c/tags/items/stones.json b/fabric/src/main/resources/data/c/tags/item/stones.json similarity index 100% rename from fabric/src/main/resources/data/c/tags/items/stones.json rename to fabric/src/main/resources/data/c/tags/item/stones.json diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index c8107efb..f01e913f 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -36,7 +36,7 @@ "depends": { "fabricloader": ">=${fabric_loader_version}", "fabric-api": "*", - "minecraft": "${minecraft_version}", + "minecraft": "${minecraft_version_range}", "java": ">=${java_version}" }, "suggests": { diff --git a/forge/src/main/resources/data/c/tags/items/chests/wooden.json b/forge/src/main/resources/data/c/tags/item/chests/wooden.json similarity index 100% rename from forge/src/main/resources/data/c/tags/items/chests/wooden.json rename to forge/src/main/resources/data/c/tags/item/chests/wooden.json diff --git a/forge/src/main/resources/data/c/tags/items/cooking_oil.json b/forge/src/main/resources/data/c/tags/item/cooking_oil.json similarity index 100% rename from forge/src/main/resources/data/c/tags/items/cooking_oil.json rename to forge/src/main/resources/data/c/tags/item/cooking_oil.json diff --git a/forge/src/main/resources/data/c/tags/items/dyes.json b/forge/src/main/resources/data/c/tags/item/dyes.json similarity index 100% rename from forge/src/main/resources/data/c/tags/items/dyes.json rename to forge/src/main/resources/data/c/tags/item/dyes.json diff --git a/forge/src/main/resources/data/c/tags/items/dyes/black.json b/forge/src/main/resources/data/c/tags/item/dyes/black.json similarity index 100% rename from forge/src/main/resources/data/c/tags/items/dyes/black.json rename to forge/src/main/resources/data/c/tags/item/dyes/black.json diff --git a/forge/src/main/resources/data/c/tags/items/dyes/blue.json b/forge/src/main/resources/data/c/tags/item/dyes/blue.json similarity index 100% rename from forge/src/main/resources/data/c/tags/items/dyes/blue.json rename to forge/src/main/resources/data/c/tags/item/dyes/blue.json diff --git a/forge/src/main/resources/data/c/tags/items/dyes/brown.json b/forge/src/main/resources/data/c/tags/item/dyes/brown.json similarity index 100% rename from forge/src/main/resources/data/c/tags/items/dyes/brown.json rename to forge/src/main/resources/data/c/tags/item/dyes/brown.json diff --git a/forge/src/main/resources/data/c/tags/items/dyes/cyan.json b/forge/src/main/resources/data/c/tags/item/dyes/cyan.json similarity index 100% rename from forge/src/main/resources/data/c/tags/items/dyes/cyan.json rename to forge/src/main/resources/data/c/tags/item/dyes/cyan.json diff --git a/forge/src/main/resources/data/c/tags/items/dyes/gray.json b/forge/src/main/resources/data/c/tags/item/dyes/gray.json similarity index 100% rename from forge/src/main/resources/data/c/tags/items/dyes/gray.json rename to forge/src/main/resources/data/c/tags/item/dyes/gray.json diff --git a/forge/src/main/resources/data/c/tags/items/dyes/green.json b/forge/src/main/resources/data/c/tags/item/dyes/green.json similarity index 100% rename from forge/src/main/resources/data/c/tags/items/dyes/green.json rename to forge/src/main/resources/data/c/tags/item/dyes/green.json diff --git a/forge/src/main/resources/data/c/tags/items/dyes/light_blue.json b/forge/src/main/resources/data/c/tags/item/dyes/light_blue.json similarity index 100% rename from forge/src/main/resources/data/c/tags/items/dyes/light_blue.json rename to forge/src/main/resources/data/c/tags/item/dyes/light_blue.json diff --git a/forge/src/main/resources/data/c/tags/items/dyes/light_gray.json b/forge/src/main/resources/data/c/tags/item/dyes/light_gray.json similarity index 100% rename from forge/src/main/resources/data/c/tags/items/dyes/light_gray.json rename to forge/src/main/resources/data/c/tags/item/dyes/light_gray.json diff --git a/forge/src/main/resources/data/c/tags/items/dyes/lime.json b/forge/src/main/resources/data/c/tags/item/dyes/lime.json similarity index 100% rename from forge/src/main/resources/data/c/tags/items/dyes/lime.json rename to forge/src/main/resources/data/c/tags/item/dyes/lime.json diff --git a/forge/src/main/resources/data/c/tags/items/dyes/magenta.json b/forge/src/main/resources/data/c/tags/item/dyes/magenta.json similarity index 100% rename from forge/src/main/resources/data/c/tags/items/dyes/magenta.json rename to forge/src/main/resources/data/c/tags/item/dyes/magenta.json diff --git a/forge/src/main/resources/data/c/tags/items/dyes/orange.json b/forge/src/main/resources/data/c/tags/item/dyes/orange.json similarity index 100% rename from forge/src/main/resources/data/c/tags/items/dyes/orange.json rename to forge/src/main/resources/data/c/tags/item/dyes/orange.json diff --git a/forge/src/main/resources/data/c/tags/items/dyes/pink.json b/forge/src/main/resources/data/c/tags/item/dyes/pink.json similarity index 100% rename from forge/src/main/resources/data/c/tags/items/dyes/pink.json rename to forge/src/main/resources/data/c/tags/item/dyes/pink.json diff --git a/forge/src/main/resources/data/c/tags/items/dyes/purple.json b/forge/src/main/resources/data/c/tags/item/dyes/purple.json similarity index 100% rename from forge/src/main/resources/data/c/tags/items/dyes/purple.json rename to forge/src/main/resources/data/c/tags/item/dyes/purple.json diff --git a/forge/src/main/resources/data/c/tags/items/dyes/red.json b/forge/src/main/resources/data/c/tags/item/dyes/red.json similarity index 100% rename from forge/src/main/resources/data/c/tags/items/dyes/red.json rename to forge/src/main/resources/data/c/tags/item/dyes/red.json diff --git a/forge/src/main/resources/data/c/tags/items/dyes/white.json b/forge/src/main/resources/data/c/tags/item/dyes/white.json similarity index 100% rename from forge/src/main/resources/data/c/tags/items/dyes/white.json rename to forge/src/main/resources/data/c/tags/item/dyes/white.json diff --git a/forge/src/main/resources/data/c/tags/items/dyes/yellow.json b/forge/src/main/resources/data/c/tags/item/dyes/yellow.json similarity index 100% rename from forge/src/main/resources/data/c/tags/items/dyes/yellow.json rename to forge/src/main/resources/data/c/tags/item/dyes/yellow.json diff --git a/forge/src/main/resources/data/c/tags/items/eggs.json b/forge/src/main/resources/data/c/tags/item/eggs.json similarity index 100% rename from forge/src/main/resources/data/c/tags/items/eggs.json rename to forge/src/main/resources/data/c/tags/item/eggs.json diff --git a/forge/src/main/resources/data/c/tags/items/gems.json b/forge/src/main/resources/data/c/tags/item/gems.json similarity index 100% rename from forge/src/main/resources/data/c/tags/items/gems.json rename to forge/src/main/resources/data/c/tags/item/gems.json diff --git a/forge/src/main/resources/data/c/tags/items/gems/diamond.json b/forge/src/main/resources/data/c/tags/item/gems/diamond.json similarity index 100% rename from forge/src/main/resources/data/c/tags/items/gems/diamond.json rename to forge/src/main/resources/data/c/tags/item/gems/diamond.json diff --git a/forge/src/main/resources/data/c/tags/items/gems/emerald.json b/forge/src/main/resources/data/c/tags/item/gems/emerald.json similarity index 100% rename from forge/src/main/resources/data/c/tags/items/gems/emerald.json rename to forge/src/main/resources/data/c/tags/item/gems/emerald.json diff --git a/forge/src/main/resources/data/c/tags/items/ingots.json b/forge/src/main/resources/data/c/tags/item/ingots.json similarity index 100% rename from forge/src/main/resources/data/c/tags/items/ingots.json rename to forge/src/main/resources/data/c/tags/item/ingots.json diff --git a/forge/src/main/resources/data/c/tags/items/ingots/iron.json b/forge/src/main/resources/data/c/tags/item/ingots/iron.json similarity index 100% rename from forge/src/main/resources/data/c/tags/items/ingots/iron.json rename to forge/src/main/resources/data/c/tags/item/ingots/iron.json diff --git a/forge/src/main/resources/data/c/tags/items/nuggets.json b/forge/src/main/resources/data/c/tags/item/nuggets.json similarity index 100% rename from forge/src/main/resources/data/c/tags/items/nuggets.json rename to forge/src/main/resources/data/c/tags/item/nuggets.json diff --git a/forge/src/main/resources/data/c/tags/items/nuggets/gold.json b/forge/src/main/resources/data/c/tags/item/nuggets/gold.json similarity index 100% rename from forge/src/main/resources/data/c/tags/items/nuggets/gold.json rename to forge/src/main/resources/data/c/tags/item/nuggets/gold.json diff --git a/forge/src/main/resources/data/c/tags/items/nuggets/iron.json b/forge/src/main/resources/data/c/tags/item/nuggets/iron.json similarity index 100% rename from forge/src/main/resources/data/c/tags/items/nuggets/iron.json rename to forge/src/main/resources/data/c/tags/item/nuggets/iron.json diff --git a/forge/src/main/resources/data/c/tags/items/ores.json b/forge/src/main/resources/data/c/tags/item/ores.json similarity index 100% rename from forge/src/main/resources/data/c/tags/items/ores.json rename to forge/src/main/resources/data/c/tags/item/ores.json diff --git a/forge/src/main/resources/data/c/tags/items/rods/wooden.json b/forge/src/main/resources/data/c/tags/item/rods/wooden.json similarity index 100% rename from forge/src/main/resources/data/c/tags/items/rods/wooden.json rename to forge/src/main/resources/data/c/tags/item/rods/wooden.json diff --git a/forge/src/main/resources/data/c/tags/items/stones.json b/forge/src/main/resources/data/c/tags/item/stones.json similarity index 100% rename from forge/src/main/resources/data/c/tags/items/stones.json rename to forge/src/main/resources/data/c/tags/item/stones.json diff --git a/gradle.properties b/gradle.properties index 6c5cb501..89b5ea7e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,7 +4,7 @@ mod_name = Balm mod_author = BlayTheNinth credits = BlayTheNinth description = Abstraction Layer (but not really) for Blay's multiplatform mods -version = 10.3.2 +version = 21.0.0 group = net.blay09.mods homepage=https://mods.twelveiterations.com/mc/balm sources=https://github.com/TwelveIterationMods/Balm @@ -19,9 +19,9 @@ modrinth_release_type = release modrinth_project_id = MBAkmtvl # Minecraft -minecraft_version = 1.20.6 -minecraft_versions = 1.20.6 -minecraft_version_range = [1.20.6,1.21) +minecraft_version = 1.21-pre3 +minecraft_versions = 1.21-pre3 +minecraft_version_range = 1.21-beta.3 pack_format_number = 18 java_version = 21 @@ -36,7 +36,7 @@ neoforge_version_range = [20.6,) neoforge_loader_version_range = [1,) # Fabric -fabric_version = 0.98.0+1.20.6 +fabric_version = 0.99.5+1.21 fabric_loader_version = 0.15.11 # Dependencies diff --git a/neoforge/src/main/resources/data/c/tags/items/eggs.json b/neoforge/src/main/resources/data/c/tags/item/eggs.json similarity index 100% rename from neoforge/src/main/resources/data/c/tags/items/eggs.json rename to neoforge/src/main/resources/data/c/tags/item/eggs.json diff --git a/neoforge/src/main/resources/data/c/tags/items/nuggets.json b/neoforge/src/main/resources/data/c/tags/item/nuggets.json similarity index 100% rename from neoforge/src/main/resources/data/c/tags/items/nuggets.json rename to neoforge/src/main/resources/data/c/tags/item/nuggets.json diff --git a/neoforge/src/main/resources/data/c/tags/items/nuggets/gold.json b/neoforge/src/main/resources/data/c/tags/item/nuggets/gold.json similarity index 100% rename from neoforge/src/main/resources/data/c/tags/items/nuggets/gold.json rename to neoforge/src/main/resources/data/c/tags/item/nuggets/gold.json diff --git a/neoforge/src/main/resources/data/c/tags/items/nuggets/iron.json b/neoforge/src/main/resources/data/c/tags/item/nuggets/iron.json similarity index 100% rename from neoforge/src/main/resources/data/c/tags/items/nuggets/iron.json rename to neoforge/src/main/resources/data/c/tags/item/nuggets/iron.json diff --git a/neoforge/src/main/resources/data/c/tags/items/stones.json b/neoforge/src/main/resources/data/c/tags/item/stones.json similarity index 100% rename from neoforge/src/main/resources/data/c/tags/items/stones.json rename to neoforge/src/main/resources/data/c/tags/item/stones.json diff --git a/settings.gradle b/settings.gradle index a389f90d..ff20dad2 100644 --- a/settings.gradle +++ b/settings.gradle @@ -57,5 +57,5 @@ plugins { include("common") include("fabric") -include("forge") -include("neoforge") \ No newline at end of file +//include("forge") +//include("neoforge") \ No newline at end of file