MineLittlePony/src/main/java/com/minelittlepony/client/mixin/MixinDefaultPlayerSkin.java
2019-11-23 23:19:13 +02:00

50 lines
2 KiB
Java

package com.minelittlepony.client.mixin;
import com.minelittlepony.client.MineLittlePony;
import com.minelittlepony.client.model.entity.race.PlayerModels;
import com.minelittlepony.pony.IPonyManager;
import com.minelittlepony.settings.PonyLevel;
import net.minecraft.client.util.DefaultSkinHelper;
import net.minecraft.util.Identifier;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.UUID;
@Mixin(DefaultSkinHelper.class)
public abstract class MixinDefaultPlayerSkin {
@Inject(method = "getTexture()Lnet/minecraft/util/Identifier;",
at = @At("HEAD"),
cancellable = true)
private static void legacySkin(CallbackInfoReturnable<Identifier> cir) {
if (MineLittlePony.getInstance().getConfig().ponyLevel.get() == PonyLevel.PONIES) {
cir.setReturnValue(IPonyManager.STEVE);
}
}
@Inject(method = "getTexture(Ljava/util/UUID;)Lnet/minecraft/util/Identifier;",
at = @At("HEAD"),
cancellable = true)
private static void defaultSkin(UUID uuid, CallbackInfoReturnable<Identifier> cir) {
if (MineLittlePony.getInstance().getConfig().ponyLevel.get() == PonyLevel.PONIES) {
cir.setReturnValue(IPonyManager.getDefaultSkin(uuid));
}
}
@Inject(method = "getModel(Ljava/util/UUID;)Ljava/lang/String;",
at = @At("HEAD"),
cancellable = true)
private static void skinType(UUID uuid, CallbackInfoReturnable<String> cir) {
if (MineLittlePony.getInstance().getConfig().ponyLevel.get() == PonyLevel.PONIES) {
cir.setReturnValue(PlayerModels.forRace(MineLittlePony.getInstance().getManager()
.getPony(IPonyManager.getDefaultSkin(uuid), uuid)
.getRace(false))
.getId(IPonyManager.isSlimSkin(uuid)));
}
}
}