Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ repositories {
mavenCentral()
maven("https://maven.fabricmc.net/")
maven("https://maven.terraformersmc.com/releases/")
maven("https://maven.wispforest.io/releases/")
maven("https://api.modrinth.com/maven")
}

dependencies {
Expand All @@ -26,6 +28,10 @@ dependencies {
modImplementation("net.fabricmc:fabric-loader:${property("deps.fabric_loader")}")
modImplementation("net.fabricmc.fabric-api:fabric-api:${project.property("deps.fabric_api")}")
modImplementation("com.terraformersmc:modmenu:${project.property("deps.modmenu_version")}")

// Legacy4J integration
modCompileOnly("maven.modrinth:legacy4j:1.21.10-1.8.7+fabric")
modCompileOnly("maven.modrinth:factory-api:1.21.10-2.2.7+fabric")
}

java {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ org.gradle.parallel=true
org.gradle.configuration-cache=true

# Mod Properties
mod.version=1.1.0
mod.version=1.2.0
mod.group=com.brandonitaly
mod.id=bedrockskins
mod.name=Bedrock Skins
Expand Down
Empty file modified gradlew
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ plugins {

stonecutter {
create(rootProject) {
versions("1.21.11")
versions("1.21.9", "1.21.10", "1.21.11")
vcsVersion = "1.21.11"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,21 @@
import net.minecraft.network.codec.ByteBufCodecs;
import net.minecraft.network.codec.StreamCodec;
import net.minecraft.network.protocol.common.custom.CustomPacketPayload;
//? if >=1.21.11 {
import net.minecraft.resources.Identifier;
//?} else {
/*import net.minecraft.resources.ResourceLocation;*/
//?}

public final class BedrockSkinsNetworking {
private BedrockSkinsNetworking() {}

public static final class SkinUpdatePayload implements CustomPacketPayload {
//? if >=1.21.11 {
public static final CustomPacketPayload.Type<SkinUpdatePayload> ID = new CustomPacketPayload.Type<>(Identifier.fromNamespaceAndPath("bedrockskins", "skin_update"));
//?} else {
/*public static final CustomPacketPayload.Type<SkinUpdatePayload> ID = new CustomPacketPayload.Type<>(ResourceLocation.fromNamespaceAndPath("bedrockskins", "skin_update"));*/
//?}
public static final StreamCodec<RegistryFriendlyByteBuf, SkinUpdatePayload> CODEC = StreamCodec.composite(
UUIDUtil.STREAM_CODEC, SkinUpdatePayload::getUuid,
ByteBufCodecs.stringUtf8(32767), SkinUpdatePayload::getSkinKey,
Expand Down Expand Up @@ -65,7 +73,11 @@ public int hashCode() {
}

public static final class SetSkinPayload implements CustomPacketPayload {
//? if >=1.21.11 {
public static final CustomPacketPayload.Type<SetSkinPayload> ID = new CustomPacketPayload.Type<>(Identifier.fromNamespaceAndPath("bedrockskins", "set_skin"));
//?} else {
/*public static final CustomPacketPayload.Type<SetSkinPayload> ID = new CustomPacketPayload.Type<>(ResourceLocation.fromNamespaceAndPath("bedrockskins", "set_skin"));*/
//?}
public static final StreamCodec<RegistryFriendlyByteBuf, SetSkinPayload> CODEC = StreamCodec.composite(
ByteBufCodecs.stringUtf8(32767), SetSkinPayload::getSkinKey,
ByteBufCodecs.stringUtf8(262144), SetSkinPayload::getGeometry,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
import net.minecraft.client.model.geom.builders.LayerDefinition;
import net.minecraft.client.model.geom.builders.MeshDefinition;
import net.minecraft.client.model.geom.builders.PartDefinition;
//? if >=1.21.11 {
import net.minecraft.client.model.player.PlayerModel;
//?} else {
/*import net.minecraft.client.model.PlayerModel;*/
//?}
import net.minecraft.client.renderer.entity.state.AvatarRenderState;
import java.util.*;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.mojang.blaze3d.platform.InputConstants;
import com.brandonitaly.bedrockskins.client.gui.SkinSelectionScreen;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
Expand All @@ -15,7 +16,11 @@
import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
import net.minecraft.client.KeyMapping;
import net.minecraft.client.Minecraft;
//? if >=1.21.11 {
import net.minecraft.resources.Identifier;
//?} else {
/*import net.minecraft.resources.ResourceLocation;*/
//?}
import net.minecraft.server.packs.PackType;
import net.minecraft.server.packs.resources.ResourceManager;
import net.minecraft.server.packs.resources.ResourceManagerReloadListener;
Expand Down Expand Up @@ -44,14 +49,34 @@ public class BedrockSkinsClient implements ClientModInitializer {
@Override
public void onInitializeClient() {
//? if >1.21.8 {
//? if >=1.21.11 {
keybindCategory = KeyMapping.Category.register(Identifier.fromNamespaceAndPath("bedrockskins", "controls"));
//?} else {
/*keybindCategory = KeyMapping.Category.register(ResourceLocation.fromNamespaceAndPath("bedrockskins", "controls"));*/
//?}
//?}
registerKeyBinding();
registerCustomizationKeybinds();
registerLifecycleEvents();
registerNetworking();
}

public static net.minecraft.client.gui.screens.Screen getAppropriateSkinScreen(net.minecraft.client.gui.screens.Screen parent) {
if (FabricLoader.getInstance().isModLoaded("legacy")) {
try {
// Use reflection to avoid loading Legacy4J classes when the mod isn't present
Class<?> screenClass = Class.forName("com.brandonitaly.bedrockskins.client.gui.legacy.Legacy4JChangeSkinScreen");
var constructor = screenClass.getConstructor(net.minecraft.client.gui.screens.Screen.class);
return (net.minecraft.client.gui.screens.Screen) constructor.newInstance(parent);
} catch (Exception e) {
// Fallback to standard screen if Legacy4J integration fails
return new SkinSelectionScreen(parent);
}
} else {
return new SkinSelectionScreen(parent);
}
}

private void registerKeyBinding() {
try {
String keyId = "key.bedrockskins.open";
Expand All @@ -64,7 +89,7 @@ private void registerKeyBinding() {

ClientTickEvents.END_CLIENT_TICK.register(client -> {
while (openKey.consumeClick()) {
client.setScreen(new SkinSelectionScreen(client.screen));
client.setScreen(getAppropriateSkinScreen(client.screen));
}
});
System.out.println("BedrockSkinsClient: Registered keybinding (K)");
Expand Down Expand Up @@ -174,9 +199,15 @@ private void registerLifecycleEvents() {

private final class Reloader implements IdentifiableResourceReloadListener, ResourceManagerReloadListener {
@Override
//? if >=1.21.11 {
public Identifier getFabricId() {
return Identifier.fromNamespaceAndPath("bedrockskins", "reloader");
}
//?} else {
/*public ResourceLocation getFabricId() {
return ResourceLocation.fromNamespaceAndPath("bedrockskins", "reloader");
}*/
//?}

@Override
public void onResourceManagerReload(ResourceManager manager) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
import com.brandonitaly.bedrockskins.client.gui.SkinSelectionScreen;
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
import com.terraformersmc.modmenu.api.ModMenuApi;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.client.gui.screens.Screen;

public class ModMenuIntegration implements ModMenuApi {
private static final boolean LEGACY4J_LOADED = FabricLoader.getInstance().isModLoaded("legacy");

@Override
public ConfigScreenFactory<?> getModConfigScreenFactory() {
return parent -> new SkinSelectionScreen((Screen) parent);
return parent -> BedrockSkinsClient.getAppropriateSkinScreen((Screen) parent);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,37 @@
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.player.RemotePlayer;
//? if >=1.21.11 {
import net.minecraft.resources.Identifier;
//?} else {
/*import net.minecraft.resources.ResourceLocation;*/
//?}
import net.minecraft.world.entity.player.PlayerModelPart;
import net.minecraft.world.entity.player.PlayerSkin;
import net.minecraft.core.ClientAsset.ResourceTexture;

public class PreviewPlayer extends RemotePlayer {

//? if >=1.21.11 {
private Identifier forcedCape = null;
//?} else {
/*private ResourceLocation forcedCape = null;*/
//?}

public PreviewPlayer(ClientLevel world, GameProfile profile) {
super(world, profile);
}

// Sets a cape to be forced on the player preview
//? if >=1.21.11 {
public void setForcedCape(Identifier cape) {
this.forcedCape = cape;
}
//?} else {
/*public void setForcedCape(ResourceLocation cape) {
this.forcedCape = cape;
}*/
//?}

@Override
public PlayerSkin getSkin() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,13 @@
import net.minecraft.network.chat.Component;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.client.renderer.RenderPipelines;
//? if >=1.21.11 {
import net.minecraft.resources.Identifier;
import net.minecraft.util.Util;
//?} else {
/*import net.minecraft.resources.ResourceLocation;
import net.minecraft.Util;*/
//?}
import net.minecraft.world.phys.Vec3;
import net.minecraft.client.renderer.entity.EntityRenderDispatcher;
import org.joml.Quaternionf;
Expand Down Expand Up @@ -191,9 +196,17 @@ public class SkinCell {

// Hover rotation state
private float hoverYaw = 0f; // degrees
//? if >=1.21.11 {
private long lastHoverTime = Util.getMillis();
//?} else {
/*private long lastHoverTime = Util.getMillis();*/
//?}

//? if >=1.21.11 {
private static final Identifier EQUIPPED_BORDER = Identifier.fromNamespaceAndPath("bedrockskins", "container/equipped_item_border");
//?} else {
/*private static final ResourceLocation EQUIPPED_BORDER = ResourceLocation.fromNamespaceAndPath("bedrockskins", "container/equipped_item_border");*/
//?}

public SkinCell(LoadedSkin skin) {
this.skin = skin;
Expand Down Expand Up @@ -250,7 +263,11 @@ public void render(GuiGraphics context, int x, int y, int w, int h, boolean hove

if (player != null) {
// Update hover rotation state (increment while hovered, reset instantly when not hovered)
//? if >=1.21.11 {
long now = Util.getMillis();
//?} else {
/*long now = Util.getMillis();*/
//?}
long dt = Math.max(0, now - lastHoverTime);
lastHoverTime = now;
if (hovered) {
Expand Down
Loading
Loading