aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/shcm/shsupercm/fabric/citresewn/mixin/AtlasPreparationMixin.java
blob: 7a6cfa15ec50abf265dac506a354111de217cbd1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package shcm.shsupercm.fabric.citresewn.mixin;

import net.minecraft.client.render.model.SpriteAtlasManager;
import net.minecraft.util.Identifier;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyVariable;

@Mixin(SpriteAtlasManager.AtlasPreparation.class)
public abstract class AtlasPreparationMixin {

    @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));
        }
        return id;
    }
}