Skip to content

Commit

Permalink
Port to 1.20.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Benonardo committed Sep 23, 2023
1 parent 78ab96d commit 8146a7d
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 71 deletions.
12 changes: 3 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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"
Expand Down
15 changes: 6 additions & 9 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
archives_base_name=skin-textures
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -12,36 +14,30 @@
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 {

public AbstractClientPlayerEntityMixin(World world, BlockPos pos, float yaw, GameProfile gameProfile) {
super(world, pos, yaw, gameProfile);
}

@Inject(method = "getSkinTexture", at = @At("HEAD"), cancellable = true)
protected void useResourcePackSkinIfPresent(CallbackInfoReturnable<Identifier> 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<Identifier> 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<Identifier> 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
);
}

}

This file was deleted.

2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
],
"depends": {
"fabricloader": ">=0.14.18",
"minecraft": "~1.20",
"minecraft": ">=1.20.2",
"java": ">=17"
}
}
1 change: 0 additions & 1 deletion src/main/resources/skin-textures.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"compatibilityLevel": "JAVA_17",
"client": [
"AbstractClientPlayerEntityMixin",
"DummyClientPlayerEntityMixin",
"OtherClientPlayerEntityMixin",
"SkullBlockEntityRendererMixin"
],
Expand Down

0 comments on commit 8146a7d

Please sign in to comment.