aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/ResourceFinderMixin.java
blob: 0abdf766f4af85728855aee002cd1e4abe6f7173 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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);
    }
}