Skip to content

Commit

Permalink
Finish 1.21.4 support.
Browse files Browse the repository at this point in the history
  • Loading branch information
IMB11 committed Dec 17, 2024
1 parent b0ddf61 commit 9e19fa9
Show file tree
Hide file tree
Showing 12 changed files with 85 additions and 31 deletions.
4 changes: 2 additions & 2 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ plugins {

stonecutter {
create(rootProject) {
versions '1.21.3', '1.21'
vcsVersion = '1.21.3'
versions '1.21.4', '1.21.3', '1.21'
vcsVersion = '1.21.4'
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,12 @@ public void swingArmsGently(float totalDeltaTick) {

public void setHeadPos(float headYaw, float headPitch) {
this.head.yaw = headYaw;
this.hat.yaw = headYaw;
this.head.pitch = headPitch;

//? if =1.21 {
/*this.hat.yaw = headYaw;
this.hat.pitch = headPitch;
*///?}
}

public void waveCapeGently(float totalDeltaTick) {
Expand All @@ -169,17 +172,4 @@ public void waveCapeGently(float totalDeltaTick) {
*///?}
}
}

//? >=1.21.2 {
public static class NoEntityCapeModel extends net.minecraft.client.render.entity.model.PlayerCapeModel {
public NoEntityCapeModel(ModelPart modelPart) {
super(modelPart);
}

public void waveCapeGently(float totalDeltaTick) {
float f = MathHelper.sin(totalDeltaTick * 0.067F) * 0.05F;
this.cape.pitch = f;
}
}
//?}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,24 @@ protected void renderWidget(DrawContext guiGraphics, int mouseX, int mouseY, flo
var matrices = guiGraphics.getMatrices();
matrices.push();
// Translate the matrix forward so its above rendered playermodels
matrices.translate(0, 0, 10000);
// matrices.translate(0, 0, 500);
guiGraphics.drawTexture(
//? >=1.21.2 {
RenderLayer::getGuiTextured,
//?}
ARROW_TEXTURES, getX(), getY(), width, height, this.type.u,
ARROW_TEXTURES,
getX(),
getY(),
//? >=1.21.2 {
this.type.u,
(this.active ? (this.hovered || this.focused ? this.type.height : 0) : this.type.height),
//?}
width,
height,
//? <1.21.2 {
/*this.type.u,
(this.active ? (this.hovered || this.focused ? this.type.height : 0) : this.type.height),
*///?}
this.type.width, this.type.height, 64, 64
);
matrices.pop();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ public static SkinPreset generateDefaultPreset() {
return new SkinPreset(skin, name);
}

return new SkinPreset(new UrlSkin(skinQueryResult.skinURL(), skinQueryResult.modelType()), name);
try (var urlSkin = new UrlSkin(skinQueryResult.skinURL(), skinQueryResult.modelType())) {
return new SkinPreset(urlSkin.saveToConfig(), name);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ public void fetchSkin() {
var id = SkinShuffle.id("skin/" + getSerializationId().getPath() + "/" + Math.abs(getTextureUniqueness().hashCode()));
var textureManager = MinecraftClient.getInstance().getTextureManager();

if (textureManager.getOrDefault(id, null) == null) {
//? if <1.21.4 {
/*if (textureManager.getOrDefault(id, null) == null) {
*///?} else {
if (textureManager.textures.get(id) == null) {
//?}
// Texture doesn't exist, we need to fetch it.
fetching = true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,24 @@ public ConfigSkin saveToConfig() {
var textureName = String.valueOf(Math.abs(getTexture().hashCode()));
var configSkin = new ConfigSkin(textureName, getModel());

var resourceManager = MinecraftClient.getInstance().getResourceManager();

try (ResourceTexture.TextureData data = ResourceTexture.TextureData.load(resourceManager, getTexture())) {
var resourceManager = MinecraftClient.getInstance().getResourceManager();
//? if <1.21.4 {
/*try (ResourceTexture.TextureData data = ResourceTexture.TextureData.load(resourceManager, getTexture())) {
var nativeImage = data.getImage();
nativeImage.writeTo(configSkin.getFile());
} catch (IOException e) {
throw new RuntimeException("Failed to save ResourceSkin to config.", e);
}
*///?} else {
try (var resource = new ResourceTexture(getTexture())){
var resourceTex = resource.loadContents(resourceManager);
var image = resourceTex.image();
image.writeTo(configSkin.getFile());
} catch (IOException e) {
throw new RuntimeException("Failed to save ResourceSkin to config.", e);
}
//?}

return configSkin;
}
Expand Down
14 changes: 12 additions & 2 deletions src/main/java/com/mineblock11/skinshuffle/client/skin/UrlSkin.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import kong.unirest.Unirest;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.client.texture.AbstractTexture;
import net.minecraft.client.texture.PlayerSkinTexture;
import net.minecraft.util.Identifier;
import org.jetbrains.annotations.Nullable;

Expand Down Expand Up @@ -113,7 +112,8 @@ public ConfigSkin saveToConfig() {

Path temporaryFilePath = cacheFolder.resolve(Math.abs(url.hashCode()) + ".png");

return new PlayerSkinTexture(temporaryFilePath.toFile(), url, Identifier.of("minecraft", "textures/entity/player/wide/steve.png"), true, () -> {
//? if <1.21.4 {
/*return new net.minecraft.client.texture.PlayerSkinTexture(temporaryFilePath.toFile(), url, Identifier.of("minecraft", "textures/entity/player/wide/steve.png"), true, () -> {
completionCallback.run();
try {
Expand All @@ -124,6 +124,16 @@ public ConfigSkin saveToConfig() {
throw new RuntimeException(e);
}
});
*///?} else {
// Download URL to temporary file path.
// Create a new NativeImageBackedTexture from the temporary file path.
// Return the NativeImageBackedTexture.
try (net.minecraft.client.texture.NativeImage image = net.minecraft.client.texture.PlayerSkinTextureDownloader.download(temporaryFilePath.toFile().toPath(), url)) {
var texture = new net.minecraft.client.texture.NativeImageBackedTexture(image);
completionCallback.run();
return texture;
}
//?}
} catch (Exception e) {
SkinShuffle.LOGGER.warn("Failed to load skin from URL: " + url, e);
return null;
Expand Down
21 changes: 21 additions & 0 deletions src/main/resources/aw/1.21.4.accesswidener
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
accessWidener v1 named

accessible method net/minecraft/client/QuickPlay startSingleplayer (Lnet/minecraft/client/MinecraftClient;Ljava/lang/String;)V
accessible method net/minecraft/client/QuickPlay startMultiplayer (Lnet/minecraft/client/MinecraftClient;Ljava/lang/String;)V
accessible method net/minecraft/client/QuickPlay startRealms (Lnet/minecraft/client/MinecraftClient;Lnet/minecraft/client/realms/RealmsClient;Ljava/lang/String;)V
accessible class net/minecraft/client/toast/ToastManager$Entry
accessible class net/minecraft/server/world/ServerChunkLoadingManager$EntityTracker
accessible field net/minecraft/server/world/ServerChunkLoadingManager entityTrackers Lit/unimi/dsi/fastutil/ints/Int2ObjectMap;
accessible field net/minecraft/server/world/ServerChunkLoadingManager$EntityTracker entry Lnet/minecraft/server/network/EntityTrackerEntry;
accessible field net/minecraft/server/world/ServerChunkLoadingManager$EntityTracker listeners Ljava/util/Set;
accessible method net/minecraft/client/gui/widget/ClickableWidget drawScrollableText (Lnet/minecraft/client/gui/DrawContext;Lnet/minecraft/client/font/TextRenderer;Lnet/minecraft/text/Text;IIIII)V
accessible method net/minecraft/client/gui/widget/CyclingButtonWidget <init> (IIIILnet/minecraft/text/Text;Lnet/minecraft/text/Text;ILjava/lang/Object;Lnet/minecraft/client/gui/widget/CyclingButtonWidget$Values;Ljava/util/function/Function;Ljava/util/function/Function;Lnet/minecraft/client/gui/widget/CyclingButtonWidget$UpdateCallback;Lnet/minecraft/client/option/SimpleOption$TooltipFactory;Z)V

accessible method net/minecraft/client/texture/NativeImage setColor (III)V
accessible method net/minecraft/client/texture/NativeImage getColor (II)I
accessible field net/minecraft/client/render/entity/model/PlayerCapeModel cape Lnet/minecraft/client/model/ModelPart;

accessible method net/minecraft/client/texture/PlayerSkinTextureDownloader download (Ljava/nio/file/Path;Ljava/lang/String;)Lnet/minecraft/client/texture/NativeImage;
accessible method net/minecraft/client/texture/ReloadableTexture load (Lnet/minecraft/client/texture/NativeImage;ZZ)V
accessible field net/minecraft/client/texture/TextureManager textures Ljava/util/Map;
accessible field net/minecraft/client/texture/ReloadableTexture textureId Lnet/minecraft/util/Identifier;
2 changes: 1 addition & 1 deletion stonecutter.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins.apply "dev.kikugie.stonecutter"
stonecutter.active "1.21.3" /* [SC] DO NOT EDIT */
stonecutter.active "1.21.4" /* [SC] DO NOT EDIT */

stonecutter.registerChiseled tasks.register("chiseledBuild", stonecutter.chiseled) {
setGroup "project"
Expand Down
4 changes: 1 addition & 3 deletions versions/1.21.3/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
runtime.modmenu=12.0.0-beta.1
runtime.etf=LEywH685
runtime.tslatentitystatus=TPx3jh9Z
runtime.provis=yJQU660b

mod.target=>=1.21.2 <=1.21.3

deps.spruceui=6.2.0+1.21.3
deps.yacl=3.6.1+1.21.2-fabric
deps.yacl=3.6.2+1.21.2-fabric

deps.fabric_api=0.108.0+1.21.3
deps.yarn=1.21.3+build.2
10 changes: 10 additions & 0 deletions versions/1.21.4/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
runtime.modmenu=13.0.0-beta.1
runtime.etf=Aan0aaUL

mod.target=1.21.4

deps.spruceui=6.2.0+1.21.3
deps.yacl=3.6.2+1.21.4-fabric

deps.fabric_api=0.112.1+1.21.4
deps.yarn=1.21.4+build.2
4 changes: 1 addition & 3 deletions versions/1.21/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
runtime.modmenu=11.0.1
runtime.etf=O3jDICoH
runtime.tslatentitystatus=zGVbOJOH
runtime.provis=XnZ8MDSy

mod.target=>=1.21 <=1.21.1

deps.spruceui=5.1.0+1.21
deps.cicada=0.8.1+1.21-and-above
deps.yacl=3.6.1+1.21-fabric
deps.yacl=3.6.2+1.21-fabric

deps.fabric_api=0.100.4+1.21
deps.yarn=1.21+build.7

0 comments on commit 9e19fa9

Please sign in to comment.