From 176af22c7615a8db08bb57cf295188000599423d Mon Sep 17 00:00:00 2001 From: SHsuperCM Date: Mon, 2 Jan 2023 13:14:11 +0200 Subject: Unwrapping cleanup --- .../fabric/citresewn/mixin/AtlasPreparationMixin.java | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/AtlasPreparationMixin.java b/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/AtlasPreparationMixin.java index 1cc8b54..7a6cfa1 100644 --- a/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/AtlasPreparationMixin.java +++ b/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/AtlasPreparationMixin.java @@ -1,28 +1,22 @@ package shcm.shsupercm.fabric.citresewn.mixin; import net.minecraft.client.render.model.SpriteAtlasManager; -import net.minecraft.client.texture.Sprite; import net.minecraft.util.Identifier; -import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import org.spongepowered.asm.mixin.injection.ModifyVariable; @Mixin(SpriteAtlasManager.AtlasPreparation.class) public abstract class AtlasPreparationMixin { - @Shadow public @Nullable abstract Sprite getSprite(Identifier id); - @Inject(method = "getSprite", cancellable = true, at = @At("HEAD")) - private void citresewn$unwrapTexturePaths(Identifier id, CallbackInfoReturnable cir) { + @ModifyVariable(method = "getSprite", argsOnly = true, at = @At("HEAD")) + private Identifier citresewn$unwrapTexturePaths(Identifier id) { if (id.getPath().endsWith(".png")) { id = id.withPath(path -> path.substring(0, path.length() - 4)); if (id.getPath().startsWith("textures/")) id = id.withPath(path -> path.substring(9)); - - cir.setReturnValue(getSprite(id)); } + return id; } } -- cgit