diff options
author | SHsuperCM <shsupercm@gmail.com> | 2023-01-02 10:40:47 +0200 |
---|---|---|
committer | SHsuperCM <shsupercm@gmail.com> | 2023-01-02 10:40:55 +0200 |
commit | b994cb2059e5ff8d6e532d83aa14779ffd7c6339 (patch) | |
tree | 707b975246bcaeb6498e89abdf94460cb5c09bff /src | |
parent | 9c28f947a88506c3183dadc921f66590a9925a66 (diff) | |
download | CITResewn-b994cb2059e5ff8d6e532d83aa14779ffd7c6339.tar.gz CITResewn-b994cb2059e5ff8d6e532d83aa14779ffd7c6339.tar.bz2 CITResewn-b994cb2059e5ff8d6e532d83aa14779ffd7c6339.zip |
Moved new resource/atlas mixins out of Defaults
This is to prepare for future cit modeling api
Diffstat (limited to 'src')
-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); + } +} |