From 8146a7d02414a8eb9cfb49a1c8b82b13ee236914 Mon Sep 17 00:00:00 2001 From: Benonardo <75318636+Benonardo@users.noreply.github.com> Date: Sat, 23 Sep 2023 13:34:52 +0200 Subject: [PATCH] Port to 1.20.2 --- build.gradle | 12 ++---- gradle.properties | 15 +++---- .../skintextures/SkinTexturesUtil.java | 2 +- .../AbstractClientPlayerEntityMixin.java | 40 +++++++++---------- .../mixin/DummyClientPlayerEntityMixin.java | 28 ------------- src/main/resources/fabric.mod.json | 2 +- src/main/resources/skin-textures.mixins.json | 1 - 7 files changed, 29 insertions(+), 71 deletions(-) delete mode 100644 src/main/java/com/benonardo/skintextures/mixin/DummyClientPlayerEntityMixin.java diff --git a/build.gradle b/build.gradle index 49b7e2a..e4ad727 100644 --- a/build.gradle +++ b/build.gradle @@ -17,10 +17,7 @@ repositories { // Loom adds the essential maven repositories to download Minecraft and libraries from automatically. // See https://docs.gradle.org/current/userguide/declaring_repositories.html // for more information about repositories. - - maven { url = "https://jitpack.io" } maven { url = "https://api.modrinth.com/maven" } - maven { url = "https://maven.enjarai.nl/releases" } } dependencies { @@ -29,8 +26,7 @@ dependencies { mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2" modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" - // Compatibility, optional - modCompileOnly "maven.modrinth:show-me-your-skin:${project.showmeyourskin_version}" + include(implementation(annotationProcessor("io.github.llamalad7:mixinextras-fabric:0.2.0-rc.4"))) } publishMods { @@ -42,14 +38,12 @@ publishMods { curseforge { projectId = "844544" accessToken = providers.environmentVariable("CURSEFORGE_TOKEN") - minecraftVersions.add("1.20") - minecraftVersions.add("1.20.1") + minecraftVersions.add("1.20.2") } modrinth { projectId = "r3cTjDVA" accessToken = providers.environmentVariable("MODRINTH_TOKEN") - minecraftVersions.add("1.20") - minecraftVersions.add("1.20.1") + minecraftVersions.add("1.20.2") } github { repository = "Benonardo/Skin-Textures" diff --git a/gradle.properties b/gradle.properties index 00f50aa..b83dabe 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,15 +4,12 @@ org.gradle.parallel=true # Fabric Properties # check these on https://fabricmc.net/develop -minecraft_version=1.20.1 -yarn_mappings=1.20.1+build.10 -loader_version=0.14.21 +minecraft_version=1.20.2 +yarn_mappings=1.20.2+build.1 +loader_version=0.14.22 # Mod Properties -mod_version=2.0.0 -mod_changelog=Ported to 1.20(.1) and added mod publish plugin (internal) +mod_version=3.0.0 +mod_changelog=Ported to 1.20.2 maven_group=com.benonardo.skintextures -archives_base_name=skin-textures - -# Optional Dependency -showmeyourskin_version=1.6.9+1.20 \ No newline at end of file +archives_base_name=skin-textures \ No newline at end of file diff --git a/src/main/java/com/benonardo/skintextures/SkinTexturesUtil.java b/src/main/java/com/benonardo/skintextures/SkinTexturesUtil.java index 6f1a070..7fdc574 100644 --- a/src/main/java/com/benonardo/skintextures/SkinTexturesUtil.java +++ b/src/main/java/com/benonardo/skintextures/SkinTexturesUtil.java @@ -11,7 +11,7 @@ public final class SkinTexturesUtil { private SkinTexturesUtil() {} public static String getLowerCaseHash(GameProfile profile) { - return MinecraftClient.getInstance().getSkinProvider().getTextures(profile).get(MinecraftProfileTexture.Type.SKIN).getHash(); + return Integer.toHexString(MinecraftClient.getInstance().getSkinProvider().getSkinTextures(profile).texture().hashCode()); } @Nullable diff --git a/src/main/java/com/benonardo/skintextures/mixin/AbstractClientPlayerEntityMixin.java b/src/main/java/com/benonardo/skintextures/mixin/AbstractClientPlayerEntityMixin.java index 2b13b12..a48e388 100644 --- a/src/main/java/com/benonardo/skintextures/mixin/AbstractClientPlayerEntityMixin.java +++ b/src/main/java/com/benonardo/skintextures/mixin/AbstractClientPlayerEntityMixin.java @@ -1,8 +1,10 @@ package com.benonardo.skintextures.mixin; import com.benonardo.skintextures.SkinTexturesUtil; +import com.llamalad7.mixinextras.injector.ModifyReturnValue; import com.mojang.authlib.GameProfile; import net.minecraft.client.network.AbstractClientPlayerEntity; +import net.minecraft.client.util.SkinTextures; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.util.Identifier; import net.minecraft.util.math.BlockPos; @@ -12,7 +14,7 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -// Priority higher = inject at the head of everything else +// Priority higher = replace textures after everything with default priority @Mixin(value = AbstractClientPlayerEntity.class, priority = 2000) public abstract class AbstractClientPlayerEntityMixin extends PlayerEntity { @@ -20,28 +22,22 @@ public AbstractClientPlayerEntityMixin(World world, BlockPos pos, float yaw, Gam super(world, pos, yaw, gameProfile); } - @Inject(method = "getSkinTexture", at = @At("HEAD"), cancellable = true) - protected void useResourcePackSkinIfPresent(CallbackInfoReturnable cir) { - var id = SkinTexturesUtil.getResourcePackSkin(this.getGameProfile()); - if (id != null) { - cir.setReturnValue(id); - } - } - - @Inject(method = "getCapeTexture", at = @At("HEAD"), cancellable = true) - protected void useResourcePackCapeIfPresent(CallbackInfoReturnable cir) { - var id = SkinTexturesUtil.getResourcePackCape(this.getGameProfile()); - if (id != null) { - cir.setReturnValue(id); - } - } + @ModifyReturnValue(method = "getSkinTextures", at = @At("TAIL")) + protected SkinTextures useResourcePackSkinTexturesIfPresent(SkinTextures original) { + var skin = SkinTexturesUtil.getResourcePackSkin(this.getGameProfile()); + var cape = SkinTexturesUtil.getResourcePackCape(this.getGameProfile()); + var elytra = SkinTexturesUtil.getResourcePackElytra(this.getGameProfile()); + if (skin == null && cape == null && elytra == null) + return original; - @Inject(method = "getElytraTexture", at = @At("HEAD"), cancellable = true) - protected void useResourcePackElytraIfPresent(CallbackInfoReturnable cir) { - var id = SkinTexturesUtil.getResourcePackElytra(this.getGameProfile()); - if (id != null) { - cir.setReturnValue(id); - } + return new SkinTextures( + skin == null ? original.texture() : skin, + null, + cape == null ? original.capeTexture() : cape, + elytra == null ? original.elytraTexture() : elytra, + original.model(), + true + ); } } diff --git a/src/main/java/com/benonardo/skintextures/mixin/DummyClientPlayerEntityMixin.java b/src/main/java/com/benonardo/skintextures/mixin/DummyClientPlayerEntityMixin.java deleted file mode 100644 index f867498..0000000 --- a/src/main/java/com/benonardo/skintextures/mixin/DummyClientPlayerEntityMixin.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.benonardo.skintextures.mixin; - -import com.mojang.authlib.GameProfile; -import net.minecraft.util.Identifier; -import net.minecraft.util.math.BlockPos; -import net.minecraft.world.World; -import nl.enjarai.showmeyourskin.client.cursed.DummyClientPlayerEntity; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Pseudo; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Pseudo -@Mixin(DummyClientPlayerEntity.class) -public abstract class DummyClientPlayerEntityMixin extends AbstractClientPlayerEntityMixin { - - public DummyClientPlayerEntityMixin(World world, BlockPos pos, float yaw, GameProfile gameProfile) { - super(world, pos, yaw, gameProfile); - } - - @Override - @Inject(method = "getSkinTexture", at = @At("HEAD"), cancellable = true) - protected void useResourcePackSkinIfPresent(CallbackInfoReturnable cir) { - super.useResourcePackSkinIfPresent(cir); - } - -} diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 20d5212..715c44e 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -18,7 +18,7 @@ ], "depends": { "fabricloader": ">=0.14.18", - "minecraft": "~1.20", + "minecraft": ">=1.20.2", "java": ">=17" } } \ No newline at end of file diff --git a/src/main/resources/skin-textures.mixins.json b/src/main/resources/skin-textures.mixins.json index 8a50fe8..b97966f 100644 --- a/src/main/resources/skin-textures.mixins.json +++ b/src/main/resources/skin-textures.mixins.json @@ -4,7 +4,6 @@ "compatibilityLevel": "JAVA_17", "client": [ "AbstractClientPlayerEntityMixin", - "DummyClientPlayerEntityMixin", "OtherClientPlayerEntityMixin", "SkullBlockEntityRendererMixin" ],