Skip to content

Commit

Permalink
1.20.3
Browse files Browse the repository at this point in the history
  • Loading branch information
samolego committed Dec 2, 2023
1 parent b899f09 commit f82bce9
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 53 deletions.
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx1G
# Fabric Properties
minecraft_version=1.20.2
yarn_mappings=1.20.2+build.1
loader_version=0.14.22
minecraft_version=1.20.3-rc1
yarn_mappings=1.20.3-rc1+build.2
loader_version=0.15.0
#Fabric api
fabric_version=0.89.2+1.20.2
fabric_version=0.91.1+1.20.3
# Mod Properties
mod_version=2.2.1
mod_version=2.3.0
maven_group=org.samo_lego
archives_base_name=fabrictailor
# Dependencies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* Includes additional methods for skin changes.
*/
public interface TailoredPlayer {
String PROPERTY_TEXTURES = "textures";
/**
* Reloads player's skin.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
import net.minecraft.client.gui.screens.advancements.AdvancementsScreen;
import net.minecraft.client.gui.screens.inventory.InventoryScreen;
import net.minecraft.client.renderer.entity.EntityRenderDispatcher;
import net.minecraft.client.resources.SkinManager;
import net.minecraft.network.chat.CommonComponents;
import net.minecraft.network.chat.Component;
import org.joml.Quaternionf;
import org.samo_lego.fabrictailor.casts.TailoredPlayer;
import org.samo_lego.fabrictailor.client.screen.tabs.*;
import org.samo_lego.fabrictailor.mixin.client.AAbstractClientPlayer;
import org.samo_lego.fabrictailor.util.TextTranslations;
Expand Down Expand Up @@ -84,14 +84,11 @@ protected void init() {
this.addRenderableWidget(openExplorerButton);

// Checkbox for slim skin model
this.skinModelCheckbox = new Checkbox(
width / 2,
height / 2 - 12,
150,
20,
TextTranslations.create("button.fabrictailor.use_slim"),
false
);
this.skinModelCheckbox = Checkbox.builder(TextTranslations.create("button.fabrictailor.use_slim"), this.font)
.pos(width / 2,
height / 2 - 12)
.selected(false)
.build();
this.addRenderableWidget(skinModelCheckbox);

// Both should be hidden at first (default tab is "player")
Expand Down Expand Up @@ -157,7 +154,7 @@ private void clearSkin() {
if (TAILORED_SERVER) {
this.minecraft.player.connection.sendUnsignedCommand("skin clear");
} else {
((AAbstractClientPlayer) this.minecraft.player).ft_getPlayerInfo().getProfile().getProperties().removeAll(SkinManager.PROPERTY_TEXTURES);
((AAbstractClientPlayer) this.minecraft.player).ft_getPlayerInfo().getProfile().getProperties().removeAll(TailoredPlayer.PROPERTY_TEXTURES);
// Reload skin - todo
}
}
Expand All @@ -173,13 +170,13 @@ private void applyNewSkin() {
PropertyMap map = ((AAbstractClientPlayer) this.minecraft.player).ft_getPlayerInfo().getProfile().getProperties();

/*try {
map.removeAll(SkinManager.PROPERTY_TEXTURES);
map.removeAll(TailoredPlayer.PROPERTY_TEXTURES);
} catch (Exception ignored) {
// Player has no skin data, no worries
}
var skinData = packet.getSecond().readProperty();
map.put(SkinManager.PROPERTY_TEXTURES, skinData);
map.put(TailoredPlayer.PROPERTY_TEXTURES, skinData);
var skiloc = ((AAbstractClientPlayer) Minecraft.getInstance().player).ft_getPlayerInfo().getSkinLocation();
// Reload skin
Expand Down Expand Up @@ -305,7 +302,6 @@ private void drawTabs(GuiGraphics guiGraphics, int startX, int startY) {
final var selected = this.selectedTab == tab;
if (selected) {
// Rendering "selected" tab

// Showing or hiding additional buttons
this.skinModelCheckbox.visible = tab.hasSkinModels();
this.openExplorerButton.visible = tab.showExplorerButton();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
import com.mojang.datafixers.util.Pair;
import net.minecraft.client.gui.screens.advancements.AdvancementTabType;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.client.resources.SkinManager;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import org.samo_lego.fabrictailor.casts.TailoredPlayer;
import org.samo_lego.fabrictailor.mixin.client.AAbstractClientPlayer;

import java.nio.charset.StandardCharsets;
Expand Down Expand Up @@ -47,11 +47,11 @@ default boolean showModelBackwards() {
}

default Property getExtendedProperty(LocalPlayer player, MinecraftProfileTexture.Type type, String textureUrl, JsonObject metadata) {
var current = ((AAbstractClientPlayer) player).ft_getPlayerInfo().getProfile().getProperties().get(SkinManager.PROPERTY_TEXTURES).stream().findFirst();
var current = ((AAbstractClientPlayer) player).ft_getPlayerInfo().getProfile().getProperties().get(TailoredPlayer.PROPERTY_TEXTURES).stream().findFirst();
String json = current.map(property -> new String(Base64.getDecoder().decode(property.value()), StandardCharsets.UTF_8))
.orElse("{\"" + SkinManager.PROPERTY_TEXTURES + "\":{}}");
.orElse("{\"" + TailoredPlayer.PROPERTY_TEXTURES + "\":{}}");
JsonObject jsonPayload = JsonParser.parseString(json).getAsJsonObject();
JsonObject textures = jsonPayload.get(SkinManager.PROPERTY_TEXTURES).getAsJsonObject();
JsonObject textures = jsonPayload.get(TailoredPlayer.PROPERTY_TEXTURES).getAsJsonObject();

if (textures.has(type.toString())) {
JsonObject texture = textures.get(type.toString()).getAsJsonObject();
Expand All @@ -76,7 +76,7 @@ default Property getExtendedProperty(LocalPlayer player, MinecraftProfileTexture

String value = new String(Base64.getEncoder().encode(jsonPayload.toString().getBytes()));

return new Property(SkinManager.PROPERTY_TEXTURES, value);
return new Property(TailoredPlayer.PROPERTY_TEXTURES, value);
}

default AdvancementTabType getTabType() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import com.mojang.authlib.properties.Property;
import com.mojang.authlib.properties.PropertyMap;
import com.mojang.datafixers.util.Pair;
import net.minecraft.client.resources.SkinManager;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.protocol.game.*;
Expand Down Expand Up @@ -159,13 +158,13 @@ public void fabrictailor_reloadSkin() {
*/
public void fabrictailor_setSkin(Property skinData, boolean reload) {
try {
this.map.removeAll("textures");
this.map.removeAll(TailoredPlayer.PROPERTY_TEXTURES);
} catch (Exception ignored) {
// Player has no skin data, no worries
}

try {
this.map.put("textures", skinData);
this.map.put(TailoredPlayer.PROPERTY_TEXTURES, skinData);

// Saving skin data
this.skinValue = skinData.value();
Expand All @@ -185,14 +184,14 @@ public void fabrictailor_setSkin(Property skinData, boolean reload) {

@Override
public void fabrictailor_setSkin(String value, String signature, boolean reload) {
this.fabrictailor_setSkin(new Property(SkinManager.PROPERTY_TEXTURES, value, signature), reload);
this.fabrictailor_setSkin(new Property(TailoredPlayer.PROPERTY_TEXTURES, value, signature), reload);
}

@Override
public Optional<String> fabrictailor_getSkinValue() {
if (this.skinValue == null) {
try {
Property property = map.get("textures").iterator().next();
Property property = map.get(TailoredPlayer.PROPERTY_TEXTURES).iterator().next();
this.skinValue = property.value();
} catch (Exception ignored) {
// Player has no skin data, no worries
Expand All @@ -206,7 +205,7 @@ public Optional<String> fabrictailor_getSkinValue() {
public Optional<String> fabrictailor_getSkinSignature() {
if (this.skinSignature == null) {
try {
Property property = map.get("textures").iterator().next();
Property property = map.get(TailoredPlayer.PROPERTY_TEXTURES).iterator().next();
this.skinSignature = property.signature();
} catch (Exception ignored) {
// Player has no skin data, no worries
Expand All @@ -224,7 +223,7 @@ public long fabrictailor_getLastSkinChange() {
@Override
public void fabrictailor_clearSkin() {
try {
this.map.removeAll("textures");
this.map.removeAll(TailoredPlayer.PROPERTY_TEXTURES);
// Ensure that the skin is completely cleared to prevent the save bug.
this.skinValue = null;
this.skinSignature = null;
Expand All @@ -239,7 +238,7 @@ public String fabrictailor_getSkinId() {
String skin = this.skinValue;
if (skin == null) {
// Fallback to default skin
var textures = self.getGameProfile().getProperties().get("textures").stream().findAny();
var textures = self.getGameProfile().getProperties().get(TailoredPlayer.PROPERTY_TEXTURES).stream().findAny();

if (textures.isPresent()) {
skin = textures.get().value();
Expand All @@ -254,7 +253,7 @@ public String fabrictailor_getSkinId() {
// Parse as json, then get textures -> SKIN -> url value
String url = JsonParser.parseString(decoded)
.getAsJsonObject()
.getAsJsonObject("textures")
.getAsJsonObject(TailoredPlayer.PROPERTY_TEXTURES)
.getAsJsonObject("SKIN")
.getAsJsonPrimitive("url")
.getAsString();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,21 @@
package org.samo_lego.fabrictailor.mixin.client;

import com.mojang.authlib.SignatureState;
import com.mojang.authlib.properties.Property;
import com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService;
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.ModifyVariable;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(value = YggdrasilMinecraftSessionService.class, remap = false)
public class MYggDrasilMinecraftSessionService_AllSkinsAcceptor {

@Inject(method = "getSecurePropertyValue", at = @At("HEAD"), cancellable = true)
private void ft_enableInsecureValue(Property property, CallbackInfoReturnable<String> cir) {
cir.setReturnValue(property.value());
}

/**
* Disables "requireSecure" boolean in order to allow skins from all
* domains, specified in config.
*
* @param requireSecure whether to require secure connection, ignored
* @return false
* Enable unsigned skin textures.
*/
@ModifyVariable(method = "getTextures", at = @At("HEAD"), argsOnly = true)
private boolean ft_disableSecureTextures(boolean requireSecure) {
return false;
@Inject(method = "getPropertySignatureState", at = @At("HEAD"), cancellable = true)
private void ft_acceptAllSignatures(Property property, CallbackInfoReturnable<SignatureState> cir) {
cir.setReturnValue(SignatureState.SIGNED);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import net.fabricmc.fabric.api.networking.v1.PacketSender;
import net.fabricmc.fabric.api.networking.v1.ServerConfigurationNetworking;
import net.minecraft.ChatFormatting;
import net.minecraft.client.resources.SkinManager;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
Expand Down Expand Up @@ -45,11 +44,11 @@ public static void onInit(ServerGamePacketListenerImpl listener, MinecraftServer
var defSignature = config.defaultSkin.signature;

if (!defValue.isEmpty() && !defSignature.isEmpty()) {
skinData = new Property(SkinManager.PROPERTY_TEXTURES, defValue, defSignature);
skinData = new Property(TailoredPlayer.PROPERTY_TEXTURES, defValue, defSignature);
}
}
} else {
skinData = new Property(SkinManager.PROPERTY_TEXTURES, value.get(), signature.get());
skinData = new Property(TailoredPlayer.PROPERTY_TEXTURES, value.get(), signature.get());
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import com.google.gson.JsonParser;
import com.mojang.authlib.properties.Property;
import net.minecraft.client.resources.SkinManager;
import org.jetbrains.annotations.Nullable;
import org.samo_lego.fabrictailor.casts.TailoredPlayer;

import javax.net.ssl.HttpsURLConnection;
import java.io.*;
Expand Down Expand Up @@ -97,14 +97,14 @@ public static Property fetchSkinByName(String playername) {
*/
@Nullable
protected static Property getSkinFromReply(String reply) {
if(reply == null || reply.contains("error") || reply.isEmpty()) {
if (reply == null || reply.contains("error") || reply.isEmpty()) {
return null;
}

String value = reply.split("\"value\":\"")[1].split("\"")[0];
String signature = reply.split("\"signature\":\"")[1].split("\"")[0];

return new Property(SkinManager.PROPERTY_TEXTURES, value, signature);
return new Property(TailoredPlayer.PROPERTY_TEXTURES, value, signature);
}

/**
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/fabrictailor.accesswidener
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
accessWidener v2 named

accessible field net/minecraft/client/gui/screens/advancements/AdvancementsScreen WINDOW_LOCATION Lnet/minecraft/resources/ResourceLocation;
accessible field net/minecraft/client/resources/SkinManager PROPERTY_TEXTURES Ljava/lang/String;
accessible class net/minecraft/client/gui/screens/advancements/AdvancementTabType

0 comments on commit f82bce9

Please sign in to comment.