Skip to content

Commit

Permalink
Fixes #128
Browse files Browse the repository at this point in the history
  • Loading branch information
samolego committed Jan 23, 2025
1 parent 386103e commit 16379db
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx1G
# Fabric Properties
minecraft_version=1.21.4-rc3
yarn_mappings=1.21.4-rc3+build.3
loader_version=0.16.9
minecraft_version=1.21.4
yarn_mappings=1.21.4+build.8
loader_version=0.16.10

# Fabric API
fabric_version=0.110.3+1.21.4
fabric_version=0.115.0+1.21.4
# Mod Properties
mod_version=2.6.2
mod_version=2.6.3
maven_group=org.samo_lego
archives_base_name=fabrictailor

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.samo_lego.fabrictailor.client.screen.tabs.UrlSkinTab;
import org.samo_lego.fabrictailor.mixin.client.AAbstractClientPlayer;
import org.samo_lego.fabrictailor.network.payload.DefaultSkinPayload;
import org.samo_lego.fabrictailor.util.Logging;
import org.samo_lego.fabrictailor.util.TextTranslations;

import java.io.File;
Expand All @@ -39,6 +40,7 @@
import java.util.List;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.logging.Logger;

import static org.samo_lego.fabrictailor.client.ClientTailor.ALLOW_DEFAULT_SKIN;
import static org.samo_lego.fabrictailor.client.ClientTailor.TAILORED_SERVER;
Expand Down Expand Up @@ -176,6 +178,7 @@ private void clearSkin() {
}

private void applyNewSkin() {
Logging.debug("Applying new skin! On tab: " + this.selectedTab.getTitle().getString() + " with parameter: " + skinInput.getValue() + ". Slim skin: " + this.skinModelCheckbox.selected());
new CompletableFuture<>().completeAsync(() -> {
final var packetInfo = this.selectedTab.getSkinChangePacket(minecraft.player, skinInput.getValue(), this.skinModelCheckbox.selected());
packetInfo.ifPresent(packet -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public interface SkinTabType {
ItemStack getIcon();

default boolean isSelected(int startX, int startY, int mouseX, int mouseY) {
return mouseX > startX && mouseX < startX + this.width && mouseY > startY && mouseY < startY + this.height;
return mouseX > startX && mouseX < startX + width && mouseY > startY && mouseY < startY + height;
}

Optional<CustomPacketPayload> getSkinChangePacket(LocalPlayer player, String param, boolean useSlim);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ public static Property setSkinFromFile(String skinFilePath, boolean useSlim) {
Logging.debug("Fetching skin from file: " + skinFilePath);
File skinFile = new File(skinFilePath);
try (FileInputStream input = new FileInputStream(skinFile)) {
Logging.debug("Checking file type: " + input.read());
if (input.read() == 137) {
var fileType = input.read();
Logging.debug("Checking file type: " + fileType);
if (fileType == 137) {
// Check image dimensions
BufferedImage image = ImageIO.read(skinFile);
if (image.getWidth() != 64 || (image.getHeight() != 64 && image.getHeight() != 32)) {
Expand All @@ -43,7 +44,7 @@ public static Property setSkinFromFile(String skinFilePath, boolean useSlim) {

try {
Logging.debug("Uploading skin to MineSkin.");
String reply = urlRequest(URI.create("https://api.mineskin.org/generate/upload?model=" + (useSlim ? "slim" : "steve")).toURL(), false, skinFile);
String reply = urlRequest(URI.create("https://api.mineskin.org/generate/upload?v2=true&model=" + (useSlim ? "slim" : "steve")).toURL(), false, skinFile);
return getSkinFromReply(reply);
} catch (IOException e) {
// Error uploading
Expand All @@ -67,7 +68,7 @@ public static Property setSkinFromFile(String skinFilePath, boolean useSlim) {
public static Property fetchSkinByUrl(String skinUrl, boolean useSlim) {
Logging.debug("Fetching skin from URL: " + skinUrl);
try {
URL url = URI.create(String.format("https://api.mineskin.org/generate/url?url=%s&model=%s", URLEncoder.encode(skinUrl, StandardCharsets.UTF_8), useSlim ? "slim" : "steve")).toURL();
URL url = URI.create(String.format("https://api.mineskin.org/generate/url?v2=true&url=%s&model=%s", URLEncoder.encode(skinUrl, StandardCharsets.UTF_8), useSlim ? "slim" : "steve")).toURL();
String reply = urlRequest(url, false, null);
return getSkinFromReply(reply);
} catch (IOException e) {
Expand Down

0 comments on commit 16379db

Please sign in to comment.