diff --git a/build.gradle b/build.gradle
index c2aa854..f40ff31 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,8 +1,8 @@
plugins {
- id 'fabric-loom' version '1.3-SNAPSHOT'
- id 'maven-publish'
- id "com.matthewprenger.cursegradle" version "1.4.0"
- id "com.modrinth.minotaur" version "2.+"
+ id 'fabric-loom' version '1.3-SNAPSHOT'
+ id 'maven-publish'
+ id "com.matthewprenger.cursegradle" version "1.4.0"
+ id "com.modrinth.minotaur" version "2.+"
}
archivesBaseName = project.archives_base_name
@@ -10,132 +10,136 @@ version = project.mod_version
group = project.maven_group
repositories {
- maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
- maven { url 'https://maven.nucleoid.xyz' }
- maven { url 'https://jitpack.io' }
- maven { url 'https://masa.dy.fi/maven' }
+ maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
+ maven { url 'https://maven.nucleoid.xyz' }
+ maven { url 'https://jitpack.io' }
+ maven { url 'https://masa.dy.fi/maven' }
+}
+
+loom {
+ accessWidenerPath = file("src/main/resources/fabrictailor.accesswidener")
}
def ENV = System.getenv()
dependencies {
- // To change the versions see the gradle.properties file
- minecraft "com.mojang:minecraft:${project.minecraft_version}"
- mappings loom.layered {
- it.officialMojangMappings {
- setNameSyntheticMembers(false)
- }
- }
+ // To change the versions see the gradle.properties file
+ minecraft "com.mojang:minecraft:${project.minecraft_version}"
+ mappings loom.layered {
+ it.officialMojangMappings {
+ setNameSyntheticMembers(false)
+ }
+ }
- modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
+ modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
- // Fabric API. This is technically optional, but you probably want it anyway.
- modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
+ // Fabric API. This is technically optional, but you probably want it anyway.
+ modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
- // Config2Brigadier
- modImplementation(include("com.github.samolego.Config2Brigadier:config2brigadier-fabric:${project.c2b_lib_version}"))
+ // Config2Brigadier
+ modImplementation(include("com.github.samolego.Config2Brigadier:config2brigadier-fabric:${project.c2b_lib_version}"))
- // LuckPerms
- modImplementation(include('me.lucko:fabric-permissions-api:0.2-SNAPSHOT'))
+ // LuckPerms
+ modImplementation(include('me.lucko:fabric-permissions-api:0.2-SNAPSHOT'))
- // Carpet
- modCompileOnly("com.github.gnembon:fabric-carpet:${project.carpet_core_version}")
- modCompileOnly('com.github.samolego.Taterzens:taterzens-fabric:1.11.4-beta3')
+ // Carpet
+ modCompileOnly("com.github.gnembon:fabric-carpet:${project.carpet_core_version}")
+ modCompileOnly('com.github.samolego.Taterzens:taterzens-fabric:1.11.4-beta3')
}
processResources {
- inputs.property "version", project.version
+ inputs.property "version", project.version
- filesMatching("fabric.mod.json") {
- expand "version": project.version
- }
+ filesMatching("fabric.mod.json") {
+ expand "version": project.version
+ }
}
tasks.withType(JavaCompile).configureEach {
- it.options.release = 17
+ it.options.release = 17
}
java {
- // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
- // if it is present.
- // If you remove this line, sources will not be generated.
- withSourcesJar()
+ // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
+ // if it is present.
+ // If you remove this line, sources will not be generated.
+ withSourcesJar()
}
jar {
- from("LICENSE") {
- rename { "${it}_${project.archivesBaseName}"}
- }
+ from("LICENSE") {
+ rename { "${it}_${project.archivesBaseName}" }
+ }
}
// configure the maven publication
publishing {
- publications {
- mavenJava(MavenPublication) {
- // add all the jars that should be included when publishing to maven
- artifact(remapJar) {
- builtBy remapJar
- }
- artifact(sourcesJar) {
- builtBy remapSourcesJar
- }
- }
- }
-
- // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
- repositories {
- // Add repositories to publish to here.
- // Notice: This block does NOT have the same function as the block in the top level.
- // The repositories here will be used for publishing your artifact, not for
- // retrieving dependencies.
- }
+ publications {
+ mavenJava(MavenPublication) {
+ // add all the jars that should be included when publishing to maven
+ artifact(remapJar) {
+ builtBy remapJar
+ }
+ artifact(sourcesJar) {
+ builtBy remapSourcesJar
+ }
+ }
+ }
+
+ // See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
+ repositories {
+ // Add repositories to publish to here.
+ // Notice: This block does NOT have the same function as the block in the top level.
+ // The repositories here will be used for publishing your artifact, not for
+ // retrieving dependencies.
+ }
}
// from FAPI https://github.com/FabricMC/fabric/blob/1.16/build.gradle
curseforge {
- if (ENV.CURSEFORGE_API_KEY) {
- apiKey = ENV.CURSEFORGE_API_KEY
- }
-
- project {
- id = "390114"
- changelog = "A changelog can be found at https://github.com/samolego/FabricTailor/releases/latest"
- releaseType = "release"
- addGameVersion "${project.minecraft_version}"
- addGameVersion "Fabric"
-
- mainArtifact(file("${project.buildDir}/libs/${archivesBaseName}-${version}.jar")) {
- displayName = "[${project.minecraft_version}] FabricTailor ${version}"
- }
-
- afterEvaluate {
- uploadTask.dependsOn("remapJar")
- }
- }
-
- options {
- forgeGradleIntegration = false
- }
+ if (ENV.CURSEFORGE_API_KEY) {
+ apiKey = ENV.CURSEFORGE_API_KEY
+ }
+
+ project {
+ id = "390114"
+ changelog = "A changelog can be found at https://github.com/samolego/FabricTailor/releases/latest"
+ releaseType = "release"
+ addGameVersion "${project.minecraft_version}"
+ addGameVersion "Fabric"
+
+ mainArtifact(file("${project.buildDir}/libs/${archivesBaseName}-${version}.jar")) {
+ displayName = "[${project.minecraft_version}] FabricTailor ${version}"
+ }
+
+ afterEvaluate {
+ uploadTask.dependsOn("remapJar")
+ }
+ }
+
+ options {
+ forgeGradleIntegration = false
+ }
}
tasks.modrinth {
- onlyIf {
- ENV.MODRINTH_TOKEN
- }
+ onlyIf {
+ ENV.MODRINTH_TOKEN
+ }
}
modrinth {
- token = ENV.MODRINTH_TOKEN
- projectId = "g8w1NapE"
- changelog = ENV.CHANGELOG ?: "A changelog can be found at https://github.com/samolego/FabricTailor/releases/tag/${version}"
- versionNumber = version
- versionName = "[${project.minecraft_version}] FabricTailor ${version}"
- versionType = "release"
+ token = ENV.MODRINTH_TOKEN
+ projectId = "g8w1NapE"
+ changelog = ENV.CHANGELOG ?: "A changelog can be found at https://github.com/samolego/FabricTailor/releases/tag/${version}"
+ versionNumber = version
+ versionName = "[${project.minecraft_version}] FabricTailor ${version}"
+ versionType = "release"
- uploadFile = file("${project.buildDir}/libs/${archivesBaseName}-${version}.jar")
+ uploadFile = file("${project.buildDir}/libs/${archivesBaseName}-${version}.jar")
- gameVersions = [project.minecraft_version]
- loaders = ['fabric', 'quilt']
+ gameVersions = [project.minecraft_version]
+ loaders = ['fabric', 'quilt']
}
\ No newline at end of file
diff --git a/gradle.properties b/gradle.properties
index c46887b..19b4a8a 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -7,7 +7,7 @@ loader_version=0.14.22
#Fabric api
fabric_version=0.89.2+1.20.2
# Mod Properties
-mod_version=2.1.3
+mod_version=2.2.0
maven_group=org.samo_lego
archives_base_name=fabrictailor
# Dependencies
diff --git a/src/main/java/org/samo_lego/fabrictailor/casts/TailoredPlayer.java b/src/main/java/org/samo_lego/fabrictailor/casts/TailoredPlayer.java
index 693f2af..059a585 100644
--- a/src/main/java/org/samo_lego/fabrictailor/casts/TailoredPlayer.java
+++ b/src/main/java/org/samo_lego/fabrictailor/casts/TailoredPlayer.java
@@ -3,6 +3,8 @@
import com.mojang.authlib.properties.Property;
import org.jetbrains.annotations.Nullable;
+import java.util.Optional;
+
/**
* Includes additional methods for skin changes.
*/
@@ -10,57 +12,127 @@ public interface TailoredPlayer {
/**
* Reloads player's skin.
*/
- void reloadSkin();
+ void fabrictailor_reloadSkin();
+
+ /**
+ * @deprecated use {@link #fabrictailor_reloadSkin()} instead.
+ */
+ @Deprecated
+ default void reloadSkin() {
+ this.fabrictailor_reloadSkin();
+ }
/**
* Sets the skin to the specified player.
*
* @param skinData skin texture data
- * @param reload whether to send packets around for skin reload
+ * @param reload whether to send packets around for skin reload
*/
- void setSkin(Property skinData, boolean reload);
+ void fabrictailor_setSkin(Property skinData, boolean reload);
+
+ /**
+ * @deprecated use {@link #fabrictailor_setSkin(Property, boolean)} instead.
+ */
+ @Deprecated
+ default void setSkin(Property skinData, boolean reload) {
+ this.fabrictailor_setSkin(skinData, reload);
+ }
/**
* Sets the skin to the specified player.
*
- * @param value skin texture value
+ * @param value skin texture value
* @param signature skin texture signature
- * @param reload whether to send packets around for skin reload
+ * @param reload whether to send packets around for skin reload
*/
- void setSkin(String value, String signature, boolean reload);
+ void fabrictailor_setSkin(String value, String signature, boolean reload);
+
+
+ /**
+ * @deprecated use {@link #fabrictailor_setSkin(String, String, boolean)} instead.
+ */
+ @Deprecated
+ default void setSkin(String value, String signature, boolean reload) {
+ this.fabrictailor_setSkin(value, signature, reload);
+ }
/**
* Gets player's skin value.
*
* @return skin value as string, null if player has no skin set.
*/
+ Optional fabrictailor_getSkinValue();
+
+
+ /**
+ * @deprecated use {@link #fabrictailor_getSkinValue()} instead.
+ */
+ @Deprecated
@Nullable
- String getSkinValue();
+ default String getSkinValue() {
+ return this.fabrictailor_getSkinValue().orElse(null);
+ }
/**
* Gets player's skin signature.
*
* @return skin signature as string, null if player has no skin set.
*/
+ Optional fabrictailor_getSkinSignature();
+
+
+ /**
+ * @deprecated use {@link #fabrictailor_getSkinSignature()} instead.
+ */
+ @Deprecated
@Nullable
- String getSkinSignature();
+ default String getSkinSignature() {
+ return this.fabrictailor_getSkinSignature().orElse(null);
+ }
/**
* Gets the most recent time when player changed their skin.
+ *
* @return time of skin change.
*/
- long getLastSkinChange();
+ long fabrictailor_getLastSkinChange();
+
+
+ /**
+ * @deprecated use {@link #fabrictailor_getLastSkinChange()} instead.
+ */
+ @Deprecated
+ default long getLastSkinChange() {
+ return this.fabrictailor_getLastSkinChange();
+ }
/**
* Resets the skin timer.
+ *
+ * @deprecated use {@link #fabrictailor_resetLastSkinChange()} ()} instead.
*/
- void resetLastSkinChange();
+ @Deprecated
+ default void resetLastSkinChange() {
+ this.fabrictailor_resetLastSkinChange();
+ }
+
+ /**
+ * Resets the skin timer.
+ */
+ void fabrictailor_resetLastSkinChange();
/**
* Clears player's skin.
+ *
+ * @deprecated use {@link #fabrictailor_clearSkin()} instead.
*/
- void clearSkin();
+ @Deprecated
+ default void clearSkin() {
+ this.fabrictailor_clearSkin();
+ }
+
+ void fabrictailor_clearSkin();
/**
@@ -73,5 +145,13 @@ public interface TailoredPlayer {
*
* @return player's skin id (hash)
*/
- String getSkinId();
+ String fabrictailor_getSkinId();
+
+ /**
+ * @deprecated use {@link #fabrictailor_getSkinId()} instead.
+ */
+ @Deprecated
+ default String getSkinId() {
+ return this.fabrictailor_getSkinId();
+ }
}
diff --git a/src/main/java/org/samo_lego/fabrictailor/client/network/SkinChangePacket.java b/src/main/java/org/samo_lego/fabrictailor/client/network/SkinChangePacket.java
index a192915..29ced90 100644
--- a/src/main/java/org/samo_lego/fabrictailor/client/network/SkinChangePacket.java
+++ b/src/main/java/org/samo_lego/fabrictailor/client/network/SkinChangePacket.java
@@ -2,8 +2,10 @@
import com.mojang.authlib.properties.Property;
import io.netty.buffer.Unpooled;
+import net.fabricmc.fabric.impl.networking.client.ClientNetworkingImpl;
import net.minecraft.network.FriendlyByteBuf;
-import net.minecraft.network.protocol.game.ServerboundCustomPayloadPacket;
+import net.minecraft.network.protocol.Packet;
+import net.minecraft.network.protocol.common.ServerCommonPacketListener;
import net.minecraft.resources.ResourceLocation;
import org.jetbrains.annotations.NotNull;
@@ -12,8 +14,8 @@
public class SkinChangePacket {
public static final ResourceLocation FABRICTAILOR_CHANNEL = new ResourceLocation(MOD_ID, "skin_change");
- public static ServerboundCustomPayloadPacket create(@NotNull Property skinData) {
- return new ServerboundCustomPayloadPacket(FABRICTAILOR_CHANNEL, generateSkinData(skinData.getValue(), skinData.getSignature()));
+ public static Packet create(@NotNull Property skinData) {
+ return ClientNetworkingImpl.createC2SPacket(FABRICTAILOR_CHANNEL, generateSkinData(skinData.value(), skinData.signature()));
}
private static FriendlyByteBuf generateSkinData(String value, String signature) {
diff --git a/src/main/java/org/samo_lego/fabrictailor/client/screen/SkinChangeScreen.java b/src/main/java/org/samo_lego/fabrictailor/client/screen/SkinChangeScreen.java
index 8dd5772..40e520b 100644
--- a/src/main/java/org/samo_lego/fabrictailor/client/screen/SkinChangeScreen.java
+++ b/src/main/java/org/samo_lego/fabrictailor/client/screen/SkinChangeScreen.java
@@ -18,7 +18,6 @@
import net.minecraft.client.gui.components.Tooltip;
import net.minecraft.client.gui.screens.Screen;
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;
@@ -37,7 +36,6 @@
import static org.samo_lego.fabrictailor.client.ClientTailor.ALLOW_DEFAULT_SKIN;
import static org.samo_lego.fabrictailor.client.ClientTailor.TAILORED_SERVER;
-import static org.samo_lego.fabrictailor.mixin.accessors.client.AAdvancementsScreen.getWINDOW_LOCATION;
@Environment(EnvType.CLIENT)
public class SkinChangeScreen extends Screen {
@@ -179,7 +177,7 @@ private void applyNewSkin() {
// Change skin clientside only todo: reload skin
PropertyMap map = ((AAbstractClientPlayer) this.minecraft.player).ft_getPlayerInfo().getProfile().getProperties();
- try {
+ /*try {
map.removeAll(SkinManager.PROPERTY_TEXTURES);
} catch (Exception ignored) {
// Player has no skin data, no worries
@@ -198,28 +196,20 @@ private void applyNewSkin() {
//var skinInfo = this.minecraft.getSkinManager().getInsecureSkinInformation(this.minecraft.player.getGameProfile());
//MinecraftProfileTexture skinTexture = skinInfo.get(MinecraftProfileTexture.Type.SKIN);
//ResourceLocation resourceLocation = this.minecraft.getSkinManager().registerTexture(skinTexture, MinecraftProfileTexture.Type.SKIN);
- // todo
+ // todo*/
}
});
return null;
});
}
- @Override
- public void tick() {
- super.tick();
- if (this.skinInput != null) {
- this.skinInput.tick();
- }
- }
-
/**
* Renders the skin changing screen.
*/
@Override
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float delta) {
// Darkens background
- this.renderBackground(guiGraphics);
+ this.renderBackground(guiGraphics, 0, 0, 0.5f);
super.render(guiGraphics, mouseX, mouseY, delta);
// Screen title
@@ -231,7 +221,7 @@ public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float delta)
// Window texture
RenderSystem.enableBlend();
- guiGraphics.blit(getWINDOW_LOCATION(), startX, startY, 0, 0, 252, 140);
+ guiGraphics.blit(AdvancementsScreen.WINDOW_LOCATION, startX, startY, 0, 0, 252, 140);
// Render input field
@@ -298,7 +288,7 @@ public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float delta)
float mousex = (float) width / 2 - 75 - mouseX;
float mousey = ((float) height / 2 - mouseY);
- InventoryScreen.renderEntityInInventoryFollowsMouse(guiGraphics, startX + 51, startY + 120, 50, mousex, mousey, this.minecraft.player);
+ //InventoryScreen.renderEntityInInventoryFollowsMouse(guiGraphics, startX + 51, startY + 120, 50, mousex, mousey, this.minecraft.player);
}
}
@@ -323,7 +313,7 @@ private void drawTabs(GuiGraphics guiGraphics, int startX, int startY, int mouse
this.selectedTab = tab;
} else if (selectedTab == tab) {
// Rendering "selected" tab
- guiGraphics.blit(AdvancementsScreen.TABS_LOCATION, startX + 224 - i * 27, startY - 28, i == 0 ? 56 : 28, 32, 28, 32);
+ //guiGraphics.blit(AdvancementsScreen.TABS_LOCATION, startX + 224 - i * 27, startY - 28, i == 0 ? 56 : 28, 32, 28, 32);
// Showing or hiding additional buttons
this.skinModelCheckbox.visible = tab.hasSkinModels();
@@ -331,7 +321,7 @@ private void drawTabs(GuiGraphics guiGraphics, int startX, int startY, int mouse
this.openExplorerButton.visible = tab.showExplorerButton();
} else {
// rendering other tabs
- guiGraphics.blit(AdvancementsScreen.TABS_LOCATION, startX + 224 - i * 27, startY - 28, i == 0 ? 56 : 28, 0, 28, i == 0 ? 31 : 29);
+ // guiGraphics.blit(AdvancementsScreen.TABS_LOCATION, startX + 224 - i * 27, startY - 28, i == 0 ? 56 : 28, 0, 28, i == 0 ? 31 : 29);
}
}
// Rendering title
diff --git a/src/main/java/org/samo_lego/fabrictailor/client/screen/tabs/SkinTabType.java b/src/main/java/org/samo_lego/fabrictailor/client/screen/tabs/SkinTabType.java
index 5074246..20d56fc 100644
--- a/src/main/java/org/samo_lego/fabrictailor/client/screen/tabs/SkinTabType.java
+++ b/src/main/java/org/samo_lego/fabrictailor/client/screen/tabs/SkinTabType.java
@@ -47,7 +47,7 @@ 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();
- String json = current.map(property -> new String(Base64.getDecoder().decode(property.getValue()), StandardCharsets.UTF_8))
+ String json = current.map(property -> new String(Base64.getDecoder().decode(property.value()), StandardCharsets.UTF_8))
.orElse("{\"" + SkinManager.PROPERTY_TEXTURES + "\":{}}");
JsonObject jsonPayload = JsonParser.parseString(json).getAsJsonObject();
JsonObject textures = jsonPayload.get(SkinManager.PROPERTY_TEXTURES).getAsJsonObject();
diff --git a/src/main/java/org/samo_lego/fabrictailor/command/SkinCommand.java b/src/main/java/org/samo_lego/fabrictailor/command/SkinCommand.java
index 6fa9b28..5e23eaa 100644
--- a/src/main/java/org/samo_lego/fabrictailor/command/SkinCommand.java
+++ b/src/main/java/org/samo_lego/fabrictailor/command/SkinCommand.java
@@ -186,7 +186,7 @@ private static int setSkinPlayer(CommandContext context) thr
}
public static void setSkin(ServerPlayer player, Supplier skinProvider) {
- long lastChange = ((TailoredPlayer) player).getLastSkinChange();
+ long lastChange = ((TailoredPlayer) player).fabrictailor_getLastSkinChange();
long now = System.currentTimeMillis();
if(now - lastChange > config.skinChangeTimer * 1000 || lastChange == 0) {
@@ -198,7 +198,7 @@ public static void setSkin(ServerPlayer player, Supplier skinProvider)
player.displayClientMessage(SKIN_SET_ERROR, false);
} else {
if (!TATERZENS_LOADED || !TaterzenSkins.setTaterzenSkin(player, skinData)) {
- ((TailoredPlayer) player).setSkin(skinData, true);
+ ((TailoredPlayer) player).fabrictailor_setSkin(skinData, true);
}
player.displayClientMessage(TextTranslations.create("command.fabrictailor.skin.set.success").withStyle(ChatFormatting.GREEN), false);
}
@@ -218,11 +218,11 @@ public static void setSkin(ServerPlayer player, Supplier skinProvider)
public static boolean clearSkin(ServerPlayer player) {
- long lastChange = ((TailoredPlayer) player).getLastSkinChange();
+ long lastChange = ((TailoredPlayer) player).fabrictailor_getLastSkinChange();
long now = System.currentTimeMillis();
if(now - lastChange > config.skinChangeTimer * 1000 || lastChange == 0) {
- ((TailoredPlayer) player).clearSkin();
+ ((TailoredPlayer) player).fabrictailor_clearSkin();
player.displayClientMessage(
TextTranslations.create("command.fabrictailor.skin.clear.success").withStyle(ChatFormatting.GREEN),
false
diff --git a/src/main/java/org/samo_lego/fabrictailor/compatibility/TaterzenSkins.java b/src/main/java/org/samo_lego/fabrictailor/compatibility/TaterzenSkins.java
index 4dffe5d..d703239 100644
--- a/src/main/java/org/samo_lego/fabrictailor/compatibility/TaterzenSkins.java
+++ b/src/main/java/org/samo_lego/fabrictailor/compatibility/TaterzenSkins.java
@@ -13,8 +13,8 @@ public static boolean setTaterzenSkin(ServerPlayer executor, Property skinData)
if (taterzen != null) {
CompoundTag skinTag = new CompoundTag();
- skinTag.putString("value", skinData.getValue());
- skinTag.putString("signature", skinData.getSignature());
+ skinTag.putString("value", skinData.value());
+ skinTag.putString("signature", skinData.signature());
taterzen.setSkinFromTag(skinTag);
taterzen.sendProfileUpdates();
diff --git a/src/main/java/org/samo_lego/fabrictailor/mixin/MServerPlayerEntity_TailoredPlayer.java b/src/main/java/org/samo_lego/fabrictailor/mixin/MServerPlayerEntity_TailoredPlayer.java
index e75022b..30b6f95 100644
--- a/src/main/java/org/samo_lego/fabrictailor/mixin/MServerPlayerEntity_TailoredPlayer.java
+++ b/src/main/java/org/samo_lego/fabrictailor/mixin/MServerPlayerEntity_TailoredPlayer.java
@@ -9,10 +9,7 @@
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.protocol.game.*;
-import net.minecraft.server.level.ChunkMap;
-import net.minecraft.server.level.ServerChunkCache;
-import net.minecraft.server.level.ServerLevel;
-import net.minecraft.server.level.ServerPlayer;
+import net.minecraft.server.level.*;
import net.minecraft.server.network.ServerGamePacketListenerImpl;
import net.minecraft.server.players.PlayerList;
import net.minecraft.world.effect.MobEffectInstance;
@@ -34,6 +31,7 @@
import java.util.ArrayList;
import java.util.Base64;
import java.util.Collections;
+import java.util.Optional;
import static org.samo_lego.fabrictailor.FabricTailor.config;
import static org.samo_lego.fabrictailor.FabricTailor.errorLog;
@@ -53,7 +51,8 @@ public abstract class MServerPlayerEntity_TailoredPlayer extends Player implemen
@Shadow
public ServerGamePacketListenerImpl connection;
- @Shadow protected abstract void completeUsingItem();
+ @Shadow
+ protected abstract void completeUsingItem();
@Unique
private String skinValue;
@@ -78,7 +77,12 @@ public MServerPlayerEntity_TailoredPlayer(Level level, BlockPos blockPos, float
*
*/
@Override
- public void reloadSkin() {
+ public void fabrictailor_reloadSkin() {
+ if (self.getServer() == null) {
+ errorLog("Tried to reload skin form client side! This should not happen!");
+ return;
+ }
+
// Refreshing in tablist for each player
PlayerList playerManager = self.getServer().getPlayerList();
playerManager.broadcastAll(new ClientboundPlayerInfoRemovePacket(new ArrayList<>(Collections.singleton(self.getUUID()))));
@@ -93,14 +97,21 @@ public void reloadSkin() {
// need to change the player entity on the client
ServerLevel level = self.serverLevel();
- this.connection.send(new ClientboundRespawnPacket(level.dimensionTypeId(),
- level.dimension(),
- BiomeManager.obfuscateSeed(level.getSeed()),
- self.gameMode.getGameModeForPlayer(),
- self.gameMode.getPreviousGameModeForPlayer(),
- level.isDebug(), level.isFlat(), (byte) 3,
- self.getLastDeathLocation(),
- this.getPortalCooldown()));
+ this.connection.send(new ClientboundRespawnPacket(
+ new CommonPlayerSpawnInfo(
+ level.dimensionTypeId(),
+ level.dimension(),
+ BiomeManager.obfuscateSeed(level.getSeed()),
+ self.gameMode.getGameModeForPlayer(),
+ self.gameMode.getPreviousGameModeForPlayer(),
+ level.isDebug(),
+ level.isFlat(),
+ self.getLastDeathLocation(),
+ this.getPortalCooldown()
+ ),
+ (byte) 3
+ )
+ );
this.connection.send(new ClientboundPlayerPositionPacket(self.getX(), self.getY(), self.getZ(), self.getYRot(), self.getXRot(), Collections.emptySet(), 0));
this.connection.send(new ClientboundSetCarriedItemPacket(this.getInventory().selected));
@@ -141,12 +152,12 @@ public void reloadSkin() {
}
/**
- * Sets the skin to the specified player and reloads it with {@link MServerPlayerEntity_TailoredPlayer#reloadSkin()} reloadSkin().
+ * Sets the skin to the specified player and reloads it with {@link MServerPlayerEntity_TailoredPlayer#fabrictailor_reloadSkin()} ()} reloadSkin().
*
* @param skinData skin texture data
* @param reload whether to send packets around for skin reload
*/
- public void setSkin(Property skinData, boolean reload) {
+ public void fabrictailor_setSkin(Property skinData, boolean reload) {
try {
this.map.removeAll("textures");
} catch (Exception ignored) {
@@ -157,12 +168,12 @@ public void setSkin(Property skinData, boolean reload) {
this.map.put("textures", skinData);
// Saving skin data
- this.skinValue = skinData.getValue();
- this.skinSignature = skinData.getSignature();
+ this.skinValue = skinData.value();
+ this.skinSignature = skinData.signature();
// Reloading skin
if (reload) {
- this.reloadSkin();
+ this.fabrictailor_reloadSkin();
}
this.lastSkinChangeTime = System.currentTimeMillis();
@@ -173,63 +184,65 @@ public void setSkin(Property skinData, boolean reload) {
}
@Override
- public void setSkin(String value, String signature, boolean reload) {
- this.setSkin(new Property(SkinManager.PROPERTY_TEXTURES, value, signature), reload);
+ public void fabrictailor_setSkin(String value, String signature, boolean reload) {
+ this.fabrictailor_setSkin(new Property(SkinManager.PROPERTY_TEXTURES, value, signature), reload);
}
@Override
- public String getSkinValue() {
- if(this.skinValue == null) {
+ public Optional fabrictailor_getSkinValue() {
+ if (this.skinValue == null) {
try {
Property property = map.get("textures").iterator().next();
- this.skinValue = property.getValue();
+ this.skinValue = property.value();
} catch (Exception ignored) {
// Player has no skin data, no worries
}
}
- return this.skinValue;
+
+ return Optional.ofNullable(this.skinValue);
}
@Override
- public String getSkinSignature() {
- if(this.skinSignature == null) {
+ public Optional fabrictailor_getSkinSignature() {
+ if (this.skinSignature == null) {
try {
Property property = map.get("textures").iterator().next();
- this.skinSignature = property.getSignature();
+ this.skinSignature = property.signature();
} catch (Exception ignored) {
// Player has no skin data, no worries
}
}
- return this.skinSignature;
+
+ return Optional.ofNullable(this.skinSignature);
}
@Override
- public long getLastSkinChange() {
+ public long fabrictailor_getLastSkinChange() {
return this.lastSkinChangeTime;
}
@Override
- public void clearSkin() {
+ public void fabrictailor_clearSkin() {
try {
this.map.removeAll("textures");
// Ensure that the skin is completely cleared to prevent the save bug.
this.skinValue = null;
this.skinSignature = null;
- this.reloadSkin();
+ this.fabrictailor_reloadSkin();
} catch (Exception ignored) {
// Player has no skin data, no worries
}
}
@Override
- public String getSkinId() {
+ public String fabrictailor_getSkinId() {
String skin = this.skinValue;
if (skin == null) {
// Fallback to default skin
var textures = self.getGameProfile().getProperties().get("textures").stream().findAny();
if (textures.isPresent()) {
- skin = textures.get().getValue();
+ skin = textures.get().value();
} else {
return STEVE;
}
@@ -251,14 +264,14 @@ public String getSkinId() {
}
@Override
- public void resetLastSkinChange() {
+ public void fabrictailor_resetLastSkinChange() {
this.lastSkinChangeTime = 0;
}
@Inject(method = "updateOptions", at = @At("TAIL"))
- private void disableCapeIfNeeded(ServerboundClientInformationPacket packet, CallbackInfo ci) {
+ private void disableCapeIfNeeded(ClientInformation clientInformation, CallbackInfo ci) {
if (!config.allowCapes) {
- byte playerModel = (byte) packet.modelCustomisation();
+ byte playerModel = (byte) clientInformation.modelCustomisation();
// Fake cape rule to be off
playerModel = (byte) (playerModel & ~(1));
@@ -269,11 +282,11 @@ private void disableCapeIfNeeded(ServerboundClientInformationPacket packet, Call
@Inject(method = "addAdditionalSaveData", at = @At("TAIL"))
private void writeCustomDataToNbt(CompoundTag tag, CallbackInfo ci) {
- if (this.getSkinValue() != null) {
+ if (this.fabrictailor_getSkinValue().isPresent()) {
CompoundTag skinDataTag = new CompoundTag();
- skinDataTag.putString("value", this.getSkinValue());
- if (this.getSkinSignature() != null) {
- skinDataTag.putString("signature", this.getSkinSignature());
+ skinDataTag.putString("value", this.fabrictailor_getSkinValue().get());
+ if (this.fabrictailor_getSkinSignature().isPresent()) {
+ skinDataTag.putString("signature", this.fabrictailor_getSkinSignature().get());
}
tag.put("fabrictailor:skin_data", skinDataTag);
@@ -287,7 +300,7 @@ private void readCustomDataFromNbt(CompoundTag tag, CallbackInfo ci) {
this.skinSignature = skinDataTag.contains("signature") ? skinDataTag.getString("signature") : null;
if (this.skinValue != null) {
- this.setSkin(this.skinValue, this.skinSignature, false);
+ this.fabrictailor_setSkin(this.skinValue, this.skinSignature, false);
}
}
}
diff --git a/src/main/java/org/samo_lego/fabrictailor/mixin/accessors/client/AAdvancementsScreen.java b/src/main/java/org/samo_lego/fabrictailor/mixin/accessors/client/AAdvancementsScreen.java
deleted file mode 100644
index b6aae1b..0000000
--- a/src/main/java/org/samo_lego/fabrictailor/mixin/accessors/client/AAdvancementsScreen.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package org.samo_lego.fabrictailor.mixin.accessors.client;
-
-import net.fabricmc.api.EnvType;
-import net.fabricmc.api.Environment;
-import net.minecraft.client.gui.screens.advancements.AdvancementsScreen;
-import net.minecraft.resources.ResourceLocation;
-import org.spongepowered.asm.mixin.Mixin;
-import org.spongepowered.asm.mixin.gen.Accessor;
-
-@Environment(EnvType.CLIENT)
-@Mixin(AdvancementsScreen.class)
-public interface AAdvancementsScreen {
- @Accessor("WINDOW_LOCATION")
- static ResourceLocation getWINDOW_LOCATION() {
- throw new AssertionError();
- }
-}
diff --git a/src/main/java/org/samo_lego/fabrictailor/mixin/client/MYggDrasilMinecraftSessionService_AllSkinsAcceptor.java b/src/main/java/org/samo_lego/fabrictailor/mixin/client/MYggDrasilMinecraftSessionService_AllSkinsAcceptor.java
index 61fdf80..1af3194 100644
--- a/src/main/java/org/samo_lego/fabrictailor/mixin/client/MYggDrasilMinecraftSessionService_AllSkinsAcceptor.java
+++ b/src/main/java/org/samo_lego/fabrictailor/mixin/client/MYggDrasilMinecraftSessionService_AllSkinsAcceptor.java
@@ -1,6 +1,5 @@
package org.samo_lego.fabrictailor.mixin.client;
-import com.google.common.net.InternetDomainName;
import com.mojang.authlib.properties.Property;
import com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService;
import org.spongepowered.asm.mixin.Mixin;
@@ -8,18 +7,13 @@
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyVariable;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
-import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
-
-import java.net.URI;
-
-import static org.samo_lego.fabrictailor.FabricTailor.config;
@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 cir) {
- cir.setReturnValue(property.getValue());
+ cir.setReturnValue(property.value());
}
/**
diff --git a/src/main/java/org/samo_lego/fabrictailor/network/NetworkHandler.java b/src/main/java/org/samo_lego/fabrictailor/network/NetworkHandler.java
index 632bb3a..1e74f24 100644
--- a/src/main/java/org/samo_lego/fabrictailor/network/NetworkHandler.java
+++ b/src/main/java/org/samo_lego/fabrictailor/network/NetworkHandler.java
@@ -15,6 +15,8 @@
import org.samo_lego.fabrictailor.casts.TailoredPlayer;
import org.samo_lego.fabrictailor.util.TextTranslations;
+import java.util.Optional;
+
import static org.samo_lego.fabrictailor.FabricTailor.THREADPOOL;
import static org.samo_lego.fabrictailor.FabricTailor.config;
import static org.samo_lego.fabrictailor.util.SkinFetcher.fetchSkinByName;
@@ -28,32 +30,33 @@ public static void onInit(ServerGamePacketListenerImpl listener, MinecraftServer
}
THREADPOOL.submit(() -> {
- String value = ((TailoredPlayer) player).getSkinValue();
- String signature = ((TailoredPlayer) player).getSkinSignature();
+ Optional value = ((TailoredPlayer) player).fabrictailor_getSkinValue();
+ Optional signature = ((TailoredPlayer) player).fabrictailor_getSkinSignature();
Property skinData = null;
- if (value == null) {
+ if (value.isEmpty() || signature.isEmpty()) {
if (!config.defaultSkin.applyToAll)
skinData = fetchSkinByName(player.getGameProfile().getName());
if (skinData == null) {
- value = config.defaultSkin.value;
- signature = config.defaultSkin.signature;
+ var defValue = config.defaultSkin.value;
+ var defSignature = config.defaultSkin.signature;
- if (!value.isEmpty() && !signature.isEmpty())
- skinData = new Property(SkinManager.PROPERTY_TEXTURES, value, signature);
+ if (!defValue.isEmpty() && !defSignature.isEmpty()) {
+ skinData = new Property(SkinManager.PROPERTY_TEXTURES, defValue, defSignature);
+ }
}
-
-
} else {
- skinData = new Property(SkinManager.PROPERTY_TEXTURES, value, signature);
+ skinData = new Property(SkinManager.PROPERTY_TEXTURES, value.get(), signature.get());
}
+
+
// Try to set skin now
if (skinData != null) {
- ((TailoredPlayer) player).setSkin(skinData, false);
+ ((TailoredPlayer) player).fabrictailor_setSkin(skinData, false);
}
- ((TailoredPlayer) player).resetLastSkinChange();
+ ((TailoredPlayer) player).fabrictailor_resetLastSkinChange();
});
}
@@ -65,12 +68,12 @@ public static FriendlyByteBuf createHelloPacket(boolean allowDefaultSkinButton)
return buf;
}
- public static void changeVanillaSkinPacket(MinecraftServer server, ServerPlayer player, ServerGamePacketListenerImpl listener, FriendlyByteBuf buf, PacketSender sender) {
+ public static void changeVanillaSkinPacket(MinecraftServer _server, ServerPlayer player, ServerGamePacketListenerImpl _listener, FriendlyByteBuf buf, PacketSender _sender) {
NetworkHandler.onSkinChangePacket(player, buf, () -> {
});
}
- public static void defaultSkinPacket(MinecraftServer server, ServerPlayer player, ServerGamePacketListenerImpl listener, FriendlyByteBuf buf, PacketSender sender) {
+ public static void defaultSkinPacket(MinecraftServer _server, ServerPlayer player, ServerGamePacketListenerImpl _listener, FriendlyByteBuf buf, PacketSender _sender) {
if (player.hasPermissions(2)) {
String value = buf.readUtf();
String signature = buf.readUtf();
@@ -84,7 +87,7 @@ public static void defaultSkinPacket(MinecraftServer server, ServerPlayer player
}
}
- public static void changeHDSkinPacket(MinecraftServer server, ServerPlayer player, ServerGamePacketListenerImpl listener, FriendlyByteBuf buf, PacketSender sender) {
+ public static void changeHDSkinPacket(MinecraftServer _server, ServerPlayer player, ServerGamePacketListenerImpl _listener, FriendlyByteBuf buf, PacketSender _sender) {
NetworkHandler.onSkinChangePacket(player, buf, () ->
player.displayClientMessage(TextTranslations.create("hint.fabrictailor.client_only")
.withStyle(ChatFormatting.DARK_PURPLE), false));
@@ -92,11 +95,11 @@ public static void changeHDSkinPacket(MinecraftServer server, ServerPlayer playe
public static void onSkinChangePacket(ServerPlayer player, FriendlyByteBuf buf, Runnable callback) {
- long lastChange = ((TailoredPlayer) player).getLastSkinChange();
+ long lastChange = ((TailoredPlayer) player).fabrictailor_getLastSkinChange();
long now = System.currentTimeMillis();
if (now - lastChange > config.skinChangeTimer * 1000 || lastChange == 0) {
- ((TailoredPlayer) player).setSkin(buf.readProperty(), true);
+ ((TailoredPlayer) player).fabrictailor_setSkin(buf.readProperty(), true);
callback.run();
} else {
// Prevent skin change spamming
diff --git a/src/main/resources/fabrictailor.accesswidener b/src/main/resources/fabrictailor.accesswidener
new file mode 100644
index 0000000..a79b6ac
--- /dev/null
+++ b/src/main/resources/fabrictailor.accesswidener
@@ -0,0 +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;
\ No newline at end of file
diff --git a/src/main/resources/fabrictailor.mixins.json b/src/main/resources/fabrictailor.mixins.json
index efa2328..b4c4e98 100644
--- a/src/main/resources/fabrictailor.mixins.json
+++ b/src/main/resources/fabrictailor.mixins.json
@@ -4,7 +4,6 @@
"package": "org.samo_lego.fabrictailor.mixin",
"compatibilityLevel": "JAVA_16",
"client": [
- "accessors.client.AAdvancementsScreen",
"client.AAbstractClientPlayer",
"client.MHttpTexture_HDEnabler",
"client.MSkinCustomizationScreen_SkinButton",