From 677ce67acf0bed1270caccef2dad2ff0bd8740ea Mon Sep 17 00:00:00 2001 From: dopadream Date: Wed, 7 Jan 2026 21:17:06 -0600 Subject: [PATCH 1/4] 26.1 support :3 --- build.gradle | 26 +++++----- gradle.properties | 11 ++-- gradle/wrapper/gradle-wrapper.properties | 2 +- .../foundationgames/animatica/Animatica.java | 8 +-- .../accessor/NativeImageAccessor.java | 5 ++ .../animatica/animation/AnimatedTexture.java | 30 +++++------ .../animatica/animation/AnimationLoader.java | 18 +++---- .../animatica/animation/AnimationMeta.java | 13 +++-- .../animatica/config/AnimaticaConfig.java | 13 +++-- .../animatica/mixin/IdentifierMixin.java | 9 ++-- .../animatica/mixin/NativeImageAccessor.java | 11 ---- .../animatica/mixin/NativeImageMixin.java | 15 ++++++ .../animatica/mixin/TextureManagerMixin.java | 4 +- .../mixin/VideoOptionsScreenMixin.java | 16 +++--- .../animatica/util/PropertyUtil.java | 3 +- .../animatica/util/TextureUtil.java | 50 +++++++++---------- .../animatica/util/Utilities.java | 6 +-- .../exception/InvalidPropertyException.java | 2 +- .../exception/MissingPropertyException.java | 2 +- src/main/resources/animatica.mixins.json | 9 ++-- src/main/resources/fabric.mod.json | 6 +-- 21 files changed, 133 insertions(+), 126 deletions(-) create mode 100644 src/main/java/io/github/foundationgames/animatica/accessor/NativeImageAccessor.java delete mode 100644 src/main/java/io/github/foundationgames/animatica/mixin/NativeImageAccessor.java create mode 100644 src/main/java/io/github/foundationgames/animatica/mixin/NativeImageMixin.java diff --git a/build.gradle b/build.gradle index 482dadc..5b19c11 100644 --- a/build.gradle +++ b/build.gradle @@ -1,44 +1,46 @@ plugins { - id 'fabric-loom' version "${loom_version}" + id "net.fabricmc.fabric-loom" version "${loom_version}" } -sourceCompatibility = JavaVersion.VERSION_21 -targetCompatibility = JavaVersion.VERSION_21 - -archivesBaseName = project.archives_base_name version = project.mod_version group = project.maven_group +base { + archivesName = project.archives_base_name +} + repositories { } dependencies { // To change the versions see the gradle.properties file minecraft "com.mojang:minecraft:${project.minecraft_version}" - mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" - modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" - modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" + + implementation "net.fabricmc:fabric-loader:${project.loader_version}" + implementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}" } processResources { inputs.property "version", project.version filesMatching("fabric.mod.json") { - expand "version": project.version + expand "version": inputs.properties.version } } tasks.withType(JavaCompile).configureEach { - it.options.encoding = "UTF-8" - it.options.release = 21 + it.options.release = 25 } java { withSourcesJar() + + sourceCompatibility = JavaVersion.VERSION_25 + targetCompatibility = JavaVersion.VERSION_25 } jar { from("LICENSE") { - rename { "${it}_${project.archivesBaseName}"} + rename { "${it}_${inputs.properties.archivesName}"} } } diff --git a/gradle.properties b/gradle.properties index 0ad5f5a..f4b1871 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,14 +1,13 @@ org.gradle.jvmargs=-Xmx1G -minecraft_version=1.21.5 -yarn_mappings=1.21.5+build.1 -loader_version=0.16.14 -loom_version=1.10-SNAPSHOT +minecraft_version=26.1-snapshot-2 +loader_version=0.18.4 +loom_version=1.14-SNAPSHOT # Fabric API -fabric_version=0.127.1+1.21.5 +fabric_api_version=0.141.2+26.1 -mod_version = 0.6.1+1.21.5 +mod_version = 0.6.2+26.1 maven_group = io.github.foundationgames archives_base_name = animatica diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index d6e308a..ac57dd1 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/java/io/github/foundationgames/animatica/Animatica.java b/src/main/java/io/github/foundationgames/animatica/Animatica.java index 039a899..1a595d5 100644 --- a/src/main/java/io/github/foundationgames/animatica/Animatica.java +++ b/src/main/java/io/github/foundationgames/animatica/Animatica.java @@ -4,8 +4,8 @@ import io.github.foundationgames.animatica.config.AnimaticaConfig; import net.fabricmc.api.ClientModInitializer; import net.fabricmc.fabric.api.resource.ResourceManagerHelper; -import net.minecraft.resource.ResourceType; -import net.minecraft.util.Identifier; +import net.minecraft.resources.Identifier; +import net.minecraft.server.packs.PackType; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -17,10 +17,10 @@ public class Animatica implements ClientModInitializer { @Override public void onInitializeClient() { - ResourceManagerHelper.get(ResourceType.CLIENT_RESOURCES).registerReloadListener(AnimationLoader.INSTANCE); + ResourceManagerHelper.get(PackType.CLIENT_RESOURCES).registerReloadListener(AnimationLoader.INSTANCE); } public static Identifier id(String path) { - return Identifier.of(NAMESPACE, path); + return Identifier.fromNamespaceAndPath(NAMESPACE, path); } } diff --git a/src/main/java/io/github/foundationgames/animatica/accessor/NativeImageAccessor.java b/src/main/java/io/github/foundationgames/animatica/accessor/NativeImageAccessor.java new file mode 100644 index 0000000..f708995 --- /dev/null +++ b/src/main/java/io/github/foundationgames/animatica/accessor/NativeImageAccessor.java @@ -0,0 +1,5 @@ +package io.github.foundationgames.animatica.accessor; + +public interface NativeImageAccessor { + long animatica$getPixels(); +} diff --git a/src/main/java/io/github/foundationgames/animatica/animation/AnimatedTexture.java b/src/main/java/io/github/foundationgames/animatica/animation/AnimatedTexture.java index 7d5436a..d5eb9ae 100644 --- a/src/main/java/io/github/foundationgames/animatica/animation/AnimatedTexture.java +++ b/src/main/java/io/github/foundationgames/animatica/animation/AnimatedTexture.java @@ -1,15 +1,9 @@ package io.github.foundationgames.animatica.animation; import com.google.common.collect.ImmutableList; +import com.mojang.blaze3d.platform.NativeImage; import io.github.foundationgames.animatica.Animatica; import io.github.foundationgames.animatica.util.TextureUtil; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.texture.NativeImage; -import net.minecraft.client.texture.NativeImageBackedTexture; -import net.minecraft.client.texture.TextureTickListener; -import net.minecraft.resource.ResourceManager; -import net.minecraft.util.Identifier; -import net.minecraft.util.math.MathHelper; import org.jetbrains.annotations.Nullable; import java.io.IOException; @@ -21,8 +15,14 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.function.Supplier; - -public class AnimatedTexture extends NativeImageBackedTexture implements TextureTickListener { +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.texture.DynamicTexture; +import net.minecraft.client.renderer.texture.TickableTexture; +import net.minecraft.resources.Identifier; +import net.minecraft.server.packs.resources.ResourceManager; +import net.minecraft.util.Mth; + +public class AnimatedTexture extends DynamicTexture implements TickableTexture { public static final ExecutorService EXECUTORS = Executors.newFixedThreadPool(4); public final Animation[] anims; @@ -32,7 +32,7 @@ public class AnimatedTexture extends NativeImageBackedTexture implements Texture private CompletableFuture frameWaitingOn = null; public static Optional tryCreate(ResourceManager resources, Identifier targetTexId, List anims) { - try (var targetTexResource = resources.getResourceOrThrow(targetTexId).getInputStream()) { + try (var targetTexResource = resources.getResourceOrThrow(targetTexId).open()) { return Optional.of(new AnimatedTexture(targetTexId::toString, resources, anims, NativeImage.read(targetTexResource))); } catch (IOException e) { Animatica.LOG.error(e); } @@ -48,7 +48,7 @@ public AnimatedTexture(Supplier name, ResourceManager resources, List MinecraftClient.getInstance().execute(this::upload)); + }, exec).thenAccept(v -> Minecraft.getInstance().execute(this::upload)); } } @@ -115,7 +115,7 @@ public void updateAndDraw(NativeImage image, boolean force, Executor exec) { @Override public void tick() { - this.updateAndDraw(this.getImage(), false, EXECUTORS); + this.updateAndDraw(this.getPixels(), false, EXECUTORS); } @Override @@ -150,7 +150,7 @@ public Animation(AnimationMeta meta, ResourceManager resources) throws IOExcepti this.width = meta.width(); this.height = meta.height(); - try (var source = resources.getResourceOrThrow(meta.source()).getInputStream()) { + try (var source = resources.getResourceOrThrow(meta.source()).open()) { this.sourceTexture = NativeImage.read(source); } @@ -256,7 +256,7 @@ public void close() { } private int getVForFrame(int frame, int textureFrameCount) { - return MathHelper.clamp(frame * this.height, 0, (textureFrameCount - 1) * this.height); + return Mth.clamp(frame * this.height, 0, (textureFrameCount - 1) * this.height); } } diff --git a/src/main/java/io/github/foundationgames/animatica/animation/AnimationLoader.java b/src/main/java/io/github/foundationgames/animatica/animation/AnimationLoader.java index 46bf2fe..1be50e4 100644 --- a/src/main/java/io/github/foundationgames/animatica/animation/AnimationLoader.java +++ b/src/main/java/io/github/foundationgames/animatica/animation/AnimationLoader.java @@ -4,10 +4,10 @@ import io.github.foundationgames.animatica.util.Flags; import io.github.foundationgames.animatica.util.exception.PropertyParseException; import net.fabricmc.fabric.api.resource.SimpleSynchronousResourceReloadListener; -import net.minecraft.client.MinecraftClient; -import net.minecraft.resource.Resource; -import net.minecraft.resource.ResourceManager; -import net.minecraft.util.Identifier; +import net.minecraft.client.Minecraft; +import net.minecraft.resources.Identifier; +import net.minecraft.server.packs.resources.Resource; +import net.minecraft.server.packs.resources.ResourceManager; import org.jetbrains.annotations.Nullable; import java.io.IOException; @@ -35,7 +35,7 @@ private AnimationLoader() { private static void findAllMCPAnimations(ResourceManager manager, BiConsumer action) { for (var path : ANIM_PATHS) { - manager.findResources(path, p -> p.getPath().endsWith(".properties")).forEach(action); + manager.listResources(path, p -> p.getPath().endsWith(".properties")).forEach(action); } } @@ -49,7 +49,7 @@ public Identifier getFabricId() { } @Override - public void reload(ResourceManager manager) { + public void onResourceManagerReload(ResourceManager manager) { this.animationIds.clear(); if (!Animatica.CONFIG.animatedTextures) { @@ -62,7 +62,7 @@ public void reload(ResourceManager manager) { findAllMCPAnimations(manager, (id, resource) -> { try { - try (var resourceInputStream = resource.getInputStream()) { + try (var resourceInputStream = resource.open()) { var ppt = new Properties(); ppt.load(resourceInputStream); @@ -80,9 +80,9 @@ public void reload(ResourceManager manager) { for (var targetId : animations.keySet()) { AnimatedTexture.tryCreate(manager, targetId, animations.get(targetId)) .ifPresent(tex -> { - var animId = Identifier.of(targetId.getNamespace(), targetId.getPath() + "-anim"); + var animId = Identifier.fromNamespaceAndPath(targetId.getNamespace(), targetId.getPath() + "-anim"); this.animationIds.put(targetId, animId); - MinecraftClient.getInstance().getTextureManager().registerTexture(animId, tex); + Minecraft.getInstance().getTextureManager().register(animId, tex); }); } diff --git a/src/main/java/io/github/foundationgames/animatica/animation/AnimationMeta.java b/src/main/java/io/github/foundationgames/animatica/animation/AnimationMeta.java index ac7f341..6982b36 100644 --- a/src/main/java/io/github/foundationgames/animatica/animation/AnimationMeta.java +++ b/src/main/java/io/github/foundationgames/animatica/animation/AnimationMeta.java @@ -4,13 +4,12 @@ import io.github.foundationgames.animatica.util.Utilities; import io.github.foundationgames.animatica.util.exception.InvalidPropertyException; import io.github.foundationgames.animatica.util.exception.PropertyParseException; -import net.minecraft.util.Identifier; -import net.minecraft.util.InvalidIdentifierException; - import java.util.HashSet; import java.util.Map; import java.util.Properties; import java.util.Set; +import net.minecraft.IdentifierException; +import net.minecraft.resources.Identifier; public record AnimationMeta( Identifier source, Identifier target, int targetX, @@ -22,11 +21,11 @@ public static AnimationMeta of(Identifier file, Properties properties) throws Pr Identifier source; Identifier target; try { - source = Utilities.processPath(file, Identifier.of(PropertyUtil.get(file, properties, "from"))); - } catch (InvalidIdentifierException ex) { throw new InvalidPropertyException(file, "from", "resource location"); } + source = Utilities.processPath(file, Identifier.parse(PropertyUtil.get(file, properties, "from"))); + } catch (IdentifierException ex) { throw new InvalidPropertyException(file, "from", "resource location"); } try { - target = Utilities.processPath(file, Identifier.of(PropertyUtil.get(file, properties, "to"))); - } catch (InvalidIdentifierException ex) { throw new InvalidPropertyException(file, "to", "resource location"); } + target = Utilities.processPath(file, Identifier.parse(PropertyUtil.get(file, properties, "to"))); + } catch (IdentifierException ex) { throw new InvalidPropertyException(file, "to", "resource location"); } return new AnimationMeta( source, target, diff --git a/src/main/java/io/github/foundationgames/animatica/config/AnimaticaConfig.java b/src/main/java/io/github/foundationgames/animatica/config/AnimaticaConfig.java index 50df044..7793347 100644 --- a/src/main/java/io/github/foundationgames/animatica/config/AnimaticaConfig.java +++ b/src/main/java/io/github/foundationgames/animatica/config/AnimaticaConfig.java @@ -2,9 +2,8 @@ import io.github.foundationgames.animatica.Animatica; import net.fabricmc.loader.api.FabricLoader; -import net.minecraft.client.MinecraftClient; -import net.minecraft.client.option.SimpleOption; - +import net.minecraft.client.Minecraft; +import net.minecraft.client.OptionInstance; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; @@ -15,7 +14,7 @@ public class AnimaticaConfig { public static final String FILE_NAME = "animatica.properties"; - private final SimpleOption animatedTexturesOption; + private final OptionInstance animatedTexturesOption; public boolean animatedTextures; public AnimaticaConfig() { @@ -25,7 +24,7 @@ public AnimaticaConfig() { Animatica.LOG.error("Error loading config during initialization!", e); } - this.animatedTexturesOption = SimpleOption.ofBoolean( + this.animatedTexturesOption = OptionInstance.createBoolean( "option.animatica.animated_textures", this.animatedTextures, value -> { @@ -33,7 +32,7 @@ public AnimaticaConfig() { try { this.save(); } catch (IOException e) { Animatica.LOG.error("Error saving config while changing in game!", e); } - MinecraftClient.getInstance().reloadResources(); + Minecraft.getInstance().reloadResourcePacks(); } ); } @@ -55,7 +54,7 @@ public Path getFile() throws IOException { return file; } - public SimpleOption getAnimatedTexturesOption() { + public OptionInstance getAnimatedTexturesOption() { return animatedTexturesOption; } diff --git a/src/main/java/io/github/foundationgames/animatica/mixin/IdentifierMixin.java b/src/main/java/io/github/foundationgames/animatica/mixin/IdentifierMixin.java index 40dfa9e..b74aa19 100644 --- a/src/main/java/io/github/foundationgames/animatica/mixin/IdentifierMixin.java +++ b/src/main/java/io/github/foundationgames/animatica/mixin/IdentifierMixin.java @@ -2,23 +2,22 @@ import io.github.foundationgames.animatica.Animatica; import io.github.foundationgames.animatica.util.Flags; -import net.minecraft.util.Identifier; +import net.minecraft.resources.Identifier; 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.CallbackInfoReturnable; -// Allows invalid characters in paths to support packs with extremely outdated formatting (because OptiFine does too) @Mixin(Identifier.class) public class IdentifierMixin { - @Inject(method = "of(Ljava/lang/String;)Lnet/minecraft/util/Identifier;", at = @At("TAIL")) + @Inject(method = "parse", at = @At("TAIL")) private static void animatica$reportInvalidIdentifierCharacters(String id, CallbackInfoReturnable ci) { - if (Flags.ALLOW_INVALID_ID_CHARS && !animatica$isPathAllowed(Identifier.splitOn(id, ':').getPath()) && !Identifier.splitOn(id, ':').getPath().startsWith("~/")) { + if (Flags.ALLOW_INVALID_ID_CHARS && !animatica$isPathAllowed(Identifier.bySeparator(id, ':').getPath()) && !Identifier.bySeparator(id, ':').getPath().startsWith("~/")) { Animatica.LOG.warn("Legacy resource pack is using an invalid namespaced identifier '{}'! DO NOT use non [a-z0-9_.-] characters for resource pack files and file names!", id); } } - @Inject(method = "isPathCharacterValid", at = @At("RETURN"), cancellable = true) + @Inject(method = "isAllowedInIdentifier", at = @At("RETURN"), cancellable = true) private static void animatica$allowInvalidCharacters(char character, CallbackInfoReturnable cir) { if (Flags.ALLOW_INVALID_ID_CHARS) { cir.setReturnValue(true); diff --git a/src/main/java/io/github/foundationgames/animatica/mixin/NativeImageAccessor.java b/src/main/java/io/github/foundationgames/animatica/mixin/NativeImageAccessor.java deleted file mode 100644 index 25037e9..0000000 --- a/src/main/java/io/github/foundationgames/animatica/mixin/NativeImageAccessor.java +++ /dev/null @@ -1,11 +0,0 @@ -package io.github.foundationgames.animatica.mixin; - -import net.minecraft.client.texture.NativeImage; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -@Mixin(NativeImage.class) -public interface NativeImageAccessor { - @Accessor("pointer") - long getPointer(); -} diff --git a/src/main/java/io/github/foundationgames/animatica/mixin/NativeImageMixin.java b/src/main/java/io/github/foundationgames/animatica/mixin/NativeImageMixin.java new file mode 100644 index 0000000..6164211 --- /dev/null +++ b/src/main/java/io/github/foundationgames/animatica/mixin/NativeImageMixin.java @@ -0,0 +1,15 @@ +package io.github.foundationgames.animatica.mixin; + +import com.mojang.blaze3d.platform.NativeImage; +import io.github.foundationgames.animatica.accessor.NativeImageAccessor; +import org.spongepowered.asm.mixin.Mixin; + +@Mixin(NativeImage.class) +public class NativeImageMixin implements NativeImageAccessor { + + @Override + public long animatica$getPixels() { + NativeImage $this = (NativeImage) (Object) this; + return $this.getPointer(); + } +} diff --git a/src/main/java/io/github/foundationgames/animatica/mixin/TextureManagerMixin.java b/src/main/java/io/github/foundationgames/animatica/mixin/TextureManagerMixin.java index 811eccc..2de71d4 100644 --- a/src/main/java/io/github/foundationgames/animatica/mixin/TextureManagerMixin.java +++ b/src/main/java/io/github/foundationgames/animatica/mixin/TextureManagerMixin.java @@ -2,8 +2,8 @@ import io.github.foundationgames.animatica.Animatica; import io.github.foundationgames.animatica.animation.AnimationLoader; -import net.minecraft.client.texture.TextureManager; -import net.minecraft.util.Identifier; +import net.minecraft.client.renderer.texture.TextureManager; +import net.minecraft.resources.Identifier; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.ModifyVariable; diff --git a/src/main/java/io/github/foundationgames/animatica/mixin/VideoOptionsScreenMixin.java b/src/main/java/io/github/foundationgames/animatica/mixin/VideoOptionsScreenMixin.java index f8f38f1..6ab21ac 100644 --- a/src/main/java/io/github/foundationgames/animatica/mixin/VideoOptionsScreenMixin.java +++ b/src/main/java/io/github/foundationgames/animatica/mixin/VideoOptionsScreenMixin.java @@ -1,17 +1,17 @@ package io.github.foundationgames.animatica.mixin; import io.github.foundationgames.animatica.Animatica; -import net.minecraft.client.gui.screen.Screen; -import net.minecraft.client.gui.screen.option.VideoOptionsScreen; -import net.minecraft.client.option.SimpleOption; -import net.minecraft.text.Text; +import net.minecraft.client.OptionInstance; +import net.minecraft.client.gui.screens.Screen; +import net.minecraft.client.gui.screens.options.VideoSettingsScreen; +import net.minecraft.network.chat.Component; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.ModifyArg; -@Mixin(VideoOptionsScreen.class) +@Mixin(VideoSettingsScreen.class) public abstract class VideoOptionsScreenMixin extends Screen { - protected VideoOptionsScreenMixin(Text title) { + protected VideoOptionsScreenMixin(Component title) { super(title); } @@ -23,8 +23,8 @@ protected VideoOptionsScreenMixin(Text title) { ), index = 0 ) - private SimpleOption[] animatica$addTextureAnimationOptionButton(SimpleOption[] old) { - var options = new SimpleOption[old.length + 1]; + private OptionInstance[] animatica$addTextureAnimationOptionButton(OptionInstance[] old) { + var options = new OptionInstance[old.length + 1]; System.arraycopy(old, 0, options, 0, old.length); options[options.length - 1] = Animatica.CONFIG.getAnimatedTexturesOption(); return options; diff --git a/src/main/java/io/github/foundationgames/animatica/util/PropertyUtil.java b/src/main/java/io/github/foundationgames/animatica/util/PropertyUtil.java index e5ce8a5..5092a5d 100644 --- a/src/main/java/io/github/foundationgames/animatica/util/PropertyUtil.java +++ b/src/main/java/io/github/foundationgames/animatica/util/PropertyUtil.java @@ -4,10 +4,9 @@ import io.github.foundationgames.animatica.util.exception.InvalidPropertyException; import io.github.foundationgames.animatica.util.exception.MissingPropertyException; import io.github.foundationgames.animatica.util.exception.PropertyParseException; -import net.minecraft.util.Identifier; - import java.util.Map; import java.util.Properties; +import net.minecraft.resources.Identifier; public enum PropertyUtil {; public static String get(Identifier file, Properties properties, String key) throws PropertyParseException { diff --git a/src/main/java/io/github/foundationgames/animatica/util/TextureUtil.java b/src/main/java/io/github/foundationgames/animatica/util/TextureUtil.java index caeed89..b9966ea 100644 --- a/src/main/java/io/github/foundationgames/animatica/util/TextureUtil.java +++ b/src/main/java/io/github/foundationgames/animatica/util/TextureUtil.java @@ -1,8 +1,8 @@ package io.github.foundationgames.animatica.util; -import io.github.foundationgames.animatica.mixin.NativeImageAccessor; -import net.minecraft.client.texture.NativeImage; -import net.minecraft.util.math.MathHelper; +import com.mojang.blaze3d.platform.NativeImage; +import io.github.foundationgames.animatica.accessor.NativeImageAccessor; +import net.minecraft.util.Mth; import org.lwjgl.system.MemoryUtil; public enum TextureUtil {; @@ -21,11 +21,11 @@ public enum TextureUtil {; * @param dv The v coordinate on the destination image to place the selection at */ public static void copy(NativeImage src, int u, int v, int w, int h, NativeImage dest, int du, int dv) { - w = MathHelper.clamp(dest.getWidth() - du, 0, w); - h = MathHelper.clamp(dest.getHeight() - dv, 0, h); + w = Mth.clamp(dest.getWidth() - du, 0, w); + h = Mth.clamp(dest.getHeight() - dv, 0, h); - long srcPtr = ((NativeImageAccessor)(Object)src).getPointer(); - long dstPtr = ((NativeImageAccessor)(Object)dest).getPointer(); + long srcPtr = ((NativeImageAccessor)(Object)src).animatica$getPixels(); + long dstPtr = ((NativeImageAccessor)(Object)dest).animatica$getPixels(); for (int row = 0; row < h; row++) { int srcRowIdx = ((v + row) * src.getWidth()) + u; @@ -55,11 +55,11 @@ public static void copy(NativeImage src, int u, int v, int w, int h, NativeImage * second (0 = solid first image, 1 = solid second image) */ public static void blendCopy(NativeImage src, int u0, int v0, int u1, int v1, int w, int h, NativeImage dest, int du, int dv, float blend) { - w = MathHelper.clamp(dest.getWidth() - du, 0, w); - h = MathHelper.clamp(dest.getHeight() - dv, 0, h); + w = Mth.clamp(dest.getWidth() - du, 0, w); + h = Mth.clamp(dest.getHeight() - dv, 0, h); - long srcPtr = ((NativeImageAccessor)(Object)src).getPointer(); - long dstPtr = ((NativeImageAccessor)(Object)dest).getPointer(); + long srcPtr = ((NativeImageAccessor)(Object)src).animatica$getPixels(); + long dstPtr = ((NativeImageAccessor)(Object)dest).animatica$getPixels(); for (int row = 0; row < h; row++) { int src0RowIdx = ((v0 + row) * src.getWidth()) + u0; @@ -72,21 +72,21 @@ public static void blendCopy(NativeImage src, int u0, int v0, int u1, int v1, in var trgRow = MemoryUtil.memIntBuffer(dstPtr + (trgRowIdx * SIZEOF_INT), w); for (int col = 0; col < w; col++) { - trgRow.put(col, lerpColor(src.getFormat(), src0Row.get(col), src1Row.get(col), blend)); + trgRow.put(col, lerpColor(src.format(), src0Row.get(col), src1Row.get(col), blend)); } } } public static int lerpColor(NativeImage.Format format, int c1, int c2, float delta) { - int a1 = (c1 >> format.getAlphaOffset()) & 0xFF; - int r1 = (c1 >> format.getRedOffset()) & 0xFF; - int g1 = (c1 >> format.getGreenOffset()) & 0xFF; - int b1 = (c1 >> format.getBlueOffset()) & 0xFF; + int a1 = (c1 >> format.alphaOffset()) & 0xFF; + int r1 = (c1 >> format.redOffset()) & 0xFF; + int g1 = (c1 >> format.greenOffset()) & 0xFF; + int b1 = (c1 >> format.blueOffset()) & 0xFF; - int a2 = (c2 >> format.getAlphaOffset()) & 0xFF; - int r2 = (c2 >> format.getRedOffset()) & 0xFF; - int g2 = (c2 >> format.getGreenOffset()) & 0xFF; - int b2 = (c2 >> format.getBlueOffset()) & 0xFF; + int a2 = (c2 >> format.alphaOffset()) & 0xFF; + int r2 = (c2 >> format.redOffset()) & 0xFF; + int g2 = (c2 >> format.greenOffset()) & 0xFF; + int b2 = (c2 >> format.blueOffset()) & 0xFF; // If the first or second color is transparent, // don't lerp any leftover rgb values and instead @@ -101,11 +101,11 @@ public static int lerpColor(NativeImage.Format format, int c1, int c2, float del b2 = b1; } - int oa = MathHelper.lerp(delta, a1, a2); - int or = MathHelper.lerp(delta, r1, r2); - int og = MathHelper.lerp(delta, g1, g2); - int ob = MathHelper.lerp(delta, b1, b2); + int oa = Mth.lerpInt(delta, a1, a2); + int or = Mth.lerpInt(delta, r1, r2); + int og = Mth.lerpInt(delta, g1, g2); + int ob = Mth.lerpInt(delta, b1, b2); - return (oa << format.getAlphaOffset()) | (or << format.getRedOffset()) | (og << format.getGreenOffset()) | (ob << format.getBlueOffset()); + return (oa << format.alphaOffset()) | (or << format.redOffset()) | (og << format.greenOffset()) | (ob << format.blueOffset()); } } diff --git a/src/main/java/io/github/foundationgames/animatica/util/Utilities.java b/src/main/java/io/github/foundationgames/animatica/util/Utilities.java index a60d22a..0a828ca 100644 --- a/src/main/java/io/github/foundationgames/animatica/util/Utilities.java +++ b/src/main/java/io/github/foundationgames/animatica/util/Utilities.java @@ -1,6 +1,6 @@ package io.github.foundationgames.animatica.util; -import net.minecraft.util.Identifier; +import net.minecraft.resources.Identifier; public enum Utilities {; public static Identifier processPath(Identifier fileRelativeTo, Identifier path) { @@ -9,10 +9,10 @@ public static Identifier processPath(Identifier fileRelativeTo, Identifier path) if (lInd > 0) { var builder = new StringBuilder(fileRelativeTo.getPath()); builder.replace(lInd, builder.length(), path.getPath().replaceFirst("\\./", "/")); - return Identifier.of(fileRelativeTo.getNamespace(), builder.toString()); + return Identifier.fromNamespaceAndPath(fileRelativeTo.getNamespace(), builder.toString()); } } else if (path.getPath().startsWith("~/")) { - return Identifier.of(path.getNamespace(), path.getPath().replaceFirst("~/", "optifine/")); + return Identifier.fromNamespaceAndPath(path.getNamespace(), path.getPath().replaceFirst("~/", "optifine/")); } return path; } diff --git a/src/main/java/io/github/foundationgames/animatica/util/exception/InvalidPropertyException.java b/src/main/java/io/github/foundationgames/animatica/util/exception/InvalidPropertyException.java index a6ae2ff..d37d3d2 100644 --- a/src/main/java/io/github/foundationgames/animatica/util/exception/InvalidPropertyException.java +++ b/src/main/java/io/github/foundationgames/animatica/util/exception/InvalidPropertyException.java @@ -1,6 +1,6 @@ package io.github.foundationgames.animatica.util.exception; -import net.minecraft.util.Identifier; +import net.minecraft.resources.Identifier; public class InvalidPropertyException extends PropertyParseException { public InvalidPropertyException(Identifier file, String key, String expectedType) { diff --git a/src/main/java/io/github/foundationgames/animatica/util/exception/MissingPropertyException.java b/src/main/java/io/github/foundationgames/animatica/util/exception/MissingPropertyException.java index 2e39bfe..e32030f 100644 --- a/src/main/java/io/github/foundationgames/animatica/util/exception/MissingPropertyException.java +++ b/src/main/java/io/github/foundationgames/animatica/util/exception/MissingPropertyException.java @@ -1,6 +1,6 @@ package io.github.foundationgames.animatica.util.exception; -import net.minecraft.util.Identifier; +import net.minecraft.resources.Identifier; public class MissingPropertyException extends PropertyParseException { public MissingPropertyException(Identifier file, String key) { diff --git a/src/main/resources/animatica.mixins.json b/src/main/resources/animatica.mixins.json index f161bb4..f4b9a98 100644 --- a/src/main/resources/animatica.mixins.json +++ b/src/main/resources/animatica.mixins.json @@ -1,15 +1,16 @@ { "required": true, - "minVersion": "0.8", "package": "io.github.foundationgames.animatica.mixin", - "compatibilityLevel": "JAVA_16", + "compatibilityLevel": "JAVA_25", "client": [ "IdentifierMixin", - "NativeImageAccessor", "TextureManagerMixin", "VideoOptionsScreenMixin" ], "injectors": { "defaultRequire": 1 - } + }, + "mixins": [ + "NativeImageMixin" + ] } diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index aa28176..2cb8907 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -26,9 +26,9 @@ "animatica.mixins.json" ], "depends": { - "fabricloader": ">=0.11.3", - "fabric": "*", - "minecraft": ">=1.21.5", + "fabricloader": ">=0.18.4", + "fabric-api": "*", + "minecraft": ">=26.1-alpha.2", "java": ">=21" } } From 822b422db7c2cd4e26cdc69a76a9dcd1e175c164 Mon Sep 17 00:00:00 2001 From: dopadream Date: Wed, 7 Jan 2026 21:29:59 -0600 Subject: [PATCH 2/4] Update VideoOptionsScreenMixin.java --- .../animatica/mixin/VideoOptionsScreenMixin.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/github/foundationgames/animatica/mixin/VideoOptionsScreenMixin.java b/src/main/java/io/github/foundationgames/animatica/mixin/VideoOptionsScreenMixin.java index 6ab21ac..4e6c249 100644 --- a/src/main/java/io/github/foundationgames/animatica/mixin/VideoOptionsScreenMixin.java +++ b/src/main/java/io/github/foundationgames/animatica/mixin/VideoOptionsScreenMixin.java @@ -19,7 +19,7 @@ protected VideoOptionsScreenMixin(Component title) { method = "addOptions", at = @At( value = "INVOKE", - target = "Lnet/minecraft/client/gui/widget/OptionListWidget;addAll([Lnet/minecraft/client/option/SimpleOption;)V" + target = "Lnet/minecraft/client/gui/components/OptionsList;addSmall([Lnet/minecraft/client/OptionInstance;)V" ), index = 0 ) From 803c20a435a42dfa95dd98e6a75368c4fc75798a Mon Sep 17 00:00:00 2001 From: dopadream Date: Wed, 7 Jan 2026 21:41:38 -0600 Subject: [PATCH 3/4] Update VideoOptionsScreenMixin.java --- .../animatica/mixin/VideoOptionsScreenMixin.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/github/foundationgames/animatica/mixin/VideoOptionsScreenMixin.java b/src/main/java/io/github/foundationgames/animatica/mixin/VideoOptionsScreenMixin.java index 4e6c249..e8a1056 100644 --- a/src/main/java/io/github/foundationgames/animatica/mixin/VideoOptionsScreenMixin.java +++ b/src/main/java/io/github/foundationgames/animatica/mixin/VideoOptionsScreenMixin.java @@ -19,7 +19,8 @@ protected VideoOptionsScreenMixin(Component title) { method = "addOptions", at = @At( value = "INVOKE", - target = "Lnet/minecraft/client/gui/components/OptionsList;addSmall([Lnet/minecraft/client/OptionInstance;)V" + target = "Lnet/minecraft/client/gui/components/OptionsList;addSmall([Lnet/minecraft/client/OptionInstance;)V", + ordinal = 1 ), index = 0 ) From 145fbd6f8b0a3a56e95358aa8c6e64cce9c21c40 Mon Sep 17 00:00:00 2001 From: dopadream Date: Wed, 7 Jan 2026 21:59:07 -0600 Subject: [PATCH 4/4] tooltip with translations --- .../foundationgames/animatica/config/AnimaticaConfig.java | 4 ++++ src/main/resources/assets/animatica/lang/be_by.json | 3 ++- src/main/resources/assets/animatica/lang/en_us.json | 3 ++- src/main/resources/assets/animatica/lang/es_mx.json | 3 ++- src/main/resources/assets/animatica/lang/fr_fr.json | 3 ++- src/main/resources/assets/animatica/lang/it_it.json | 3 ++- src/main/resources/assets/animatica/lang/ko_kr.json | 3 ++- src/main/resources/assets/animatica/lang/pl_pl.json | 3 ++- src/main/resources/assets/animatica/lang/ru_ru.json | 3 ++- src/main/resources/assets/animatica/lang/uk_ua.json | 3 ++- src/main/resources/assets/animatica/lang/vi_vn.json | 3 ++- src/main/resources/assets/animatica/lang/zh_cn.json | 3 ++- src/main/resources/assets/animatica/lang/zh_tw.json | 3 ++- 13 files changed, 28 insertions(+), 12 deletions(-) diff --git a/src/main/java/io/github/foundationgames/animatica/config/AnimaticaConfig.java b/src/main/java/io/github/foundationgames/animatica/config/AnimaticaConfig.java index 7793347..62a6eee 100644 --- a/src/main/java/io/github/foundationgames/animatica/config/AnimaticaConfig.java +++ b/src/main/java/io/github/foundationgames/animatica/config/AnimaticaConfig.java @@ -4,6 +4,8 @@ import net.fabricmc.loader.api.FabricLoader; import net.minecraft.client.Minecraft; import net.minecraft.client.OptionInstance; +import net.minecraft.network.chat.Component; + import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; @@ -11,6 +13,7 @@ public class AnimaticaConfig { public static String ANIMATED_TEXTURES_KEY = "animated_textures"; + private static final Component GRAPHICS_TOOLTIP_ANIMATIONS = Component.translatable("options.animatica.animations.tooltip"); public static final String FILE_NAME = "animatica.properties"; @@ -26,6 +29,7 @@ public AnimaticaConfig() { this.animatedTexturesOption = OptionInstance.createBoolean( "option.animatica.animated_textures", + OptionInstance.cachedConstantTooltip(GRAPHICS_TOOLTIP_ANIMATIONS), this.animatedTextures, value -> { this.animatedTextures = value; diff --git a/src/main/resources/assets/animatica/lang/be_by.json b/src/main/resources/assets/animatica/lang/be_by.json index f24d47b..3c50401 100644 --- a/src/main/resources/assets/animatica/lang/be_by.json +++ b/src/main/resources/assets/animatica/lang/be_by.json @@ -1,3 +1,4 @@ { - "option.animatica.animated_textures": "Карыстальніцкія Анімацыі" + "option.animatica.animated_textures": "Карыстальніцкія Анімацыі", + "options.animatica.animations.tooltip": "Пераключае бачнасць карыстальніцкіх анімацый праз Animatica." } diff --git a/src/main/resources/assets/animatica/lang/en_us.json b/src/main/resources/assets/animatica/lang/en_us.json index b26b134..a03d50d 100644 --- a/src/main/resources/assets/animatica/lang/en_us.json +++ b/src/main/resources/assets/animatica/lang/en_us.json @@ -1,3 +1,4 @@ { - "option.animatica.animated_textures": "Custom Animations" + "option.animatica.animated_textures": "Custom Animations", + "options.animatica.animations.tooltip": "Toggles the visibility of custom animations through Animatica." } \ No newline at end of file diff --git a/src/main/resources/assets/animatica/lang/es_mx.json b/src/main/resources/assets/animatica/lang/es_mx.json index 6034063..d8a2888 100644 --- a/src/main/resources/assets/animatica/lang/es_mx.json +++ b/src/main/resources/assets/animatica/lang/es_mx.json @@ -1,3 +1,4 @@ { - "option.animatica.animated_textures": "Animaciones personalizadas" + "option.animatica.animated_textures": "Animaciones personalizadas", + "options.animatica.animations.tooltip": "Activa o desactiva la visibilidad de animaciones personalizadas mediante Animatica." } \ No newline at end of file diff --git a/src/main/resources/assets/animatica/lang/fr_fr.json b/src/main/resources/assets/animatica/lang/fr_fr.json index b836fa5..00b3104 100644 --- a/src/main/resources/assets/animatica/lang/fr_fr.json +++ b/src/main/resources/assets/animatica/lang/fr_fr.json @@ -1,3 +1,4 @@ { - "option.animatica.animated_textures": "Animations Personalisées" + "option.animatica.animated_textures": "Animations Personalisées", + "options.animatica.animations.tooltip": "Active ou désactive la visibilité des animations personnalisées via Animatica." } diff --git a/src/main/resources/assets/animatica/lang/it_it.json b/src/main/resources/assets/animatica/lang/it_it.json index 7c98840..cfa2f48 100644 --- a/src/main/resources/assets/animatica/lang/it_it.json +++ b/src/main/resources/assets/animatica/lang/it_it.json @@ -1,3 +1,4 @@ { - "option.animatica.animated_textures": "Animazioni Personalizzate" + "option.animatica.animated_textures": "Animazioni Personalizzate", + "options.animatica.animations.tooltip": "Attiva o disattiva la visibilità delle animazioni personalizzate tramite Animatica." } diff --git a/src/main/resources/assets/animatica/lang/ko_kr.json b/src/main/resources/assets/animatica/lang/ko_kr.json index 423f9e0..e7542b5 100644 --- a/src/main/resources/assets/animatica/lang/ko_kr.json +++ b/src/main/resources/assets/animatica/lang/ko_kr.json @@ -1,3 +1,4 @@ { - "option.animatica.animated_textures": "사용자 지정 애니메이션" + "option.animatica.animated_textures": "사용자 지정 애니메이션", + "options.animatica.animations.tooltip": "Animatica를 통해 사용자 지정 애니메이션의 표시 여부를 전환합니다." } \ No newline at end of file diff --git a/src/main/resources/assets/animatica/lang/pl_pl.json b/src/main/resources/assets/animatica/lang/pl_pl.json index 667e98b..080bb80 100644 --- a/src/main/resources/assets/animatica/lang/pl_pl.json +++ b/src/main/resources/assets/animatica/lang/pl_pl.json @@ -1,3 +1,4 @@ { - "option.animatica.animated_textures": "Niestandardowe animacje" + "option.animatica.animated_textures": "Niestandardowe animacje", + "options.animatica.animations.tooltip": "Przełącza widoczność niestandardowych animacji za pomocą Animatica." } diff --git a/src/main/resources/assets/animatica/lang/ru_ru.json b/src/main/resources/assets/animatica/lang/ru_ru.json index 2f3b402..f068c98 100644 --- a/src/main/resources/assets/animatica/lang/ru_ru.json +++ b/src/main/resources/assets/animatica/lang/ru_ru.json @@ -1,3 +1,4 @@ { - "option.animatica.animated_textures": "Пользов. анимации" + "option.animatica.animated_textures": "Пользов. анимации", + "options.animatica.animations.tooltip": "Переключает видимость пользовательских анимаций через Animatica." } diff --git a/src/main/resources/assets/animatica/lang/uk_ua.json b/src/main/resources/assets/animatica/lang/uk_ua.json index b81fc67..e31aa1e 100644 --- a/src/main/resources/assets/animatica/lang/uk_ua.json +++ b/src/main/resources/assets/animatica/lang/uk_ua.json @@ -1,3 +1,4 @@ { - "option.animatica.animated_textures": "Власні анімації" + "option.animatica.animated_textures": "Власні анімації", + "options.animatica.animations.tooltip": "Перемикає видимість користувацьких анімацій через Animatica." } diff --git a/src/main/resources/assets/animatica/lang/vi_vn.json b/src/main/resources/assets/animatica/lang/vi_vn.json index 1434684..e3c33de 100644 --- a/src/main/resources/assets/animatica/lang/vi_vn.json +++ b/src/main/resources/assets/animatica/lang/vi_vn.json @@ -1,3 +1,4 @@ { - "option.animatica.animated_textures": "Hoạt hình tùy chỉnh" + "option.animatica.animated_textures": "Hoạt hình tùy chỉnh", + "options.animatica.animations.tooltip": "Bật hoặc tắt hiển thị các hoạt ảnh tùy chỉnh thông qua Animatica." } diff --git a/src/main/resources/assets/animatica/lang/zh_cn.json b/src/main/resources/assets/animatica/lang/zh_cn.json index ea2cdcf..8193c97 100644 --- a/src/main/resources/assets/animatica/lang/zh_cn.json +++ b/src/main/resources/assets/animatica/lang/zh_cn.json @@ -1,3 +1,4 @@ { - "option.animatica.animated_textures": "自定义动画" + "option.animatica.animated_textures": "自定义动画", + "options.animatica.animations.tooltip": "通过 Animatica 切换自定义动画的可见性。" } diff --git a/src/main/resources/assets/animatica/lang/zh_tw.json b/src/main/resources/assets/animatica/lang/zh_tw.json index b87c509..72c78cb 100644 --- a/src/main/resources/assets/animatica/lang/zh_tw.json +++ b/src/main/resources/assets/animatica/lang/zh_tw.json @@ -1,3 +1,4 @@ { - "option.animatica.animated_textures": "自訂動畫" + "option.animatica.animated_textures": "自訂動畫", + "options.animatica.animations.tooltip": "透過 Animatica 切換自訂動畫的可見性。" }