diff options
Diffstat (limited to 'src/main/java/shcm')
-rw-r--r-- | src/main/java/shcm/shsupercm/fabric/citresewn/mixin/AtlasPreparationMixin.java | 22 | ||||
-rw-r--r-- | src/main/java/shcm/shsupercm/fabric/citresewn/mixin/ResourceFinderMixin.java | 23 |
2 files changed, 45 insertions, 0 deletions
diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/AtlasPreparationMixin.java b/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/AtlasPreparationMixin.java new file mode 100644 index 0000000..035a95e --- /dev/null +++ b/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/AtlasPreparationMixin.java @@ -0,0 +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; + +@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<Sprite> cir) { + if (id.getPath().startsWith("textures/") && id.getPath().endsWith(".png")) + cir.setReturnValue(getSprite(new Identifier(id.getNamespace(), id.getPath().substring(9, id.getPath().length() - 4)))); + } +} diff --git a/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/ResourceFinderMixin.java b/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/ResourceFinderMixin.java new file mode 100644 index 0000000..0abdf76 --- /dev/null +++ b/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/ResourceFinderMixin.java @@ -0,0 +1,23 @@ +package shcm.shsupercm.fabric.citresewn.mixin; + +import net.minecraft.resource.ResourceFinder; +import net.minecraft.util.Identifier; +import org.spongepowered.asm.mixin.Final; +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; + +@Mixin(ResourceFinder.class) +public class ResourceFinderMixin { + + @Shadow @Final private String fileExtension; + + @Inject(method = "toResourcePath", cancellable = true, at = + @At("HEAD")) + private void citresewn$forceAbsoluteTextureIdentifier(Identifier id, CallbackInfoReturnable<Identifier> cir) { + if (id.getPath().endsWith(".png") && this.fileExtension.equals(".png")) + cir.setReturnValue(id); + } +} |