|
6 | 6 | import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
7 | 7 | import net.minecraft.client.renderer.ImageBufferDownload;
|
8 | 8 | import net.minecraft.client.resources.SkinManager;
|
9 |
| -import net.minecraft.entity.player.EntityPlayer; |
10 | 9 | import net.minecraft.util.ResourceLocation;
|
11 | 10 | import org.spongepowered.asm.mixin.Mixin;
|
12 |
| -import org.spongepowered.asm.mixin.Unique; |
13 | 11 | import org.spongepowered.asm.mixin.injection.At;
|
14 | 12 | import org.spongepowered.asm.mixin.injection.Inject;
|
15 | 13 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
16 | 14 | import roadhog360.simpleskinbackport.SimpleSkinBackport;
|
17 | 15 | import roadhog360.simpleskinbackport.client.ImageBufferDownloadPlayerSkin;
|
| 16 | +import roadhog360.simpleskinbackport.core.Utils; |
18 | 17 | import roadhog360.simpleskinbackport.ducks.INewModelData;
|
19 | 18 |
|
20 |
| -import java.util.Objects; |
21 |
| - |
22 | 19 | @Mixin(value = SkinManager.class, priority = 1100)
|
23 | 20 | public class MixinSkinManager {
|
24 | 21 | @WrapOperation(method = "func_152789_a", at = @At(value = "NEW", target = "(Ljava/lang/String;)Lnet/minecraft/util/ResourceLocation;"))
|
25 | 22 | private ResourceLocation changeDownloadLocation(String p_i1293_1_, Operation<ResourceLocation> original,
|
26 | 23 | @Local(argsOnly = true) final MinecraftProfileTexture.Type p_152789_2_,
|
27 | 24 | @Local(argsOnly = true) final SkinManager.SkinAvailableCallback p_152789_3_
|
28 | 25 | ) {
|
29 |
| - if(simpleSkinBackport$isNewPlayerWithPlayerData(p_152789_2_, p_152789_3_)) { |
| 26 | + if(Utils.isPlayer(p_152789_2_, p_152789_3_)) { |
30 | 27 | return new ResourceLocation(SimpleSkinBackport.MODID, p_i1293_1_);
|
31 | 28 | }
|
32 | 29 | return original.call(p_i1293_1_);
|
33 | 30 | }
|
34 | 31 |
|
35 | 32 | @WrapOperation(method = "func_152789_a", at = @At(value = "NEW", target = "()Lnet/minecraft/client/renderer/ImageBufferDownload;"))
|
36 | 33 | private ImageBufferDownload changeDownloadBufferManager(Operation<ImageBufferDownload> original,
|
37 |
| - @Local(argsOnly = true) final MinecraftProfileTexture.Type p_152789_2_, |
| 34 | + @Local(argsOnly = true) MinecraftProfileTexture p_152789_1_, |
| 35 | + @Local(argsOnly = true) MinecraftProfileTexture.Type p_152789_2_, |
38 | 36 | @Local(argsOnly = true) SkinManager.SkinAvailableCallback p_152789_3_) {
|
39 |
| - if(simpleSkinBackport$isNewPlayerWithPlayerData(p_152789_2_, p_152789_3_)) { |
40 |
| - return new ImageBufferDownloadPlayerSkin(); |
| 37 | + if(Utils.isPlayer(p_152789_2_, p_152789_3_)) { |
| 38 | + return new ImageBufferDownloadPlayerSkin(p_152789_1_, p_152789_3_); |
41 | 39 | }
|
42 | 40 | return original.call();
|
43 | 41 | }
|
44 | 42 |
|
45 | 43 | @Inject(method = "func_152789_a",
|
46 |
| - at = @At(value = "INVOKE", target = "Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;func_152121_a(Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;Lnet/minecraft/util/ResourceLocation;)V", |
47 |
| - shift = At.Shift.AFTER)) |
| 44 | + at = @At(value = "TAIL", target = "Lnet/minecraft/client/resources/SkinManager$SkinAvailableCallback;func_152121_a(Lcom/mojang/authlib/minecraft/MinecraftProfileTexture$Type;Lnet/minecraft/util/ResourceLocation;)V")) |
48 | 45 | private void injectCallbackSkinCheck(MinecraftProfileTexture p_152789_1_, MinecraftProfileTexture.Type p_152789_2_, SkinManager.SkinAvailableCallback p_152789_3_, CallbackInfoReturnable<ResourceLocation> cir) {
|
49 |
| - if(simpleSkinBackport$isNewPlayerWithPlayerData(p_152789_2_, p_152789_3_) && p_152789_3_ instanceof INewModelData playerData) { |
50 |
| - if(Objects.equals(p_152789_1_.getMetadata("model"), "slim")) { |
51 |
| - playerData.simpleSkinBackport$setSlim(true); |
52 |
| - } |
| 46 | + if(Utils.isPlayer(p_152789_2_, p_152789_3_) && p_152789_3_ instanceof INewModelData playerData) { |
| 47 | + Utils.setSlimFromMetadata(p_152789_1_, playerData); |
53 | 48 | }
|
54 | 49 | }
|
55 |
| - |
56 |
| - @Unique |
57 |
| - private boolean simpleSkinBackport$isNewPlayerWithPlayerData(final MinecraftProfileTexture.Type type, SkinManager.SkinAvailableCallback callback) { |
58 |
| - return type == MinecraftProfileTexture.Type.SKIN && callback instanceof EntityPlayer; |
59 |
| - } |
60 | 50 | }
|
0 commit comments