Skip to content

Commit

Permalink
Update/1.21 (#106)
Browse files Browse the repository at this point in the history
* update: 1.21-pre1

fixed ResourceLocation, skin screen and custom packet
type creation relate changes

* fix: crash with the `fabrictailor:hello` packet

* fix: tooltips wouldn't render

There's something overlapping with the text that hides tabs' titles.
So rendering the tooltip as the last step fixes the issue

* update: 1.21-pre2

well, that was easy 😁

* docs: update `PlayerList#respawn` reference

Mojang added a `RemovalReason` parameter

* update: 1.21-rc1

also update carpet to 1.4.146 (pre3)

* update: 1.21
  • Loading branch information
voidpointer0x00 authored Jun 16, 2024
1 parent 4012157 commit 14c0ae3
Show file tree
Hide file tree
Showing 12 changed files with 32 additions and 33 deletions.
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx1G
# Fabric Properties
minecraft_version=1.20.6
yarn_mappings=1.20.6+build.1
minecraft_version=1.21
yarn_mappings=1.21+build.2
loader_version=0.15.11
# Fabric API
fabric_version=0.98.0+1.20.6
fabric_version=0.99.4+1.21

# Mod Properties
mod_version=2.4.2
maven_group=org.samo_lego
archives_base_name=fabrictailor
# Dependencies
c2b_lib_version=1.2.3
carpet_core_version=1.4.141
carpet_core_version=1.4.147
3 changes: 3 additions & 0 deletions src/main/java/org/samo_lego/fabrictailor/FabricTailor.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.samo_lego.fabrictailor.config.TailorConfig;
import org.samo_lego.fabrictailor.network.NetworkHandler;
import org.samo_lego.fabrictailor.network.payload.DefaultSkinPayload;
import org.samo_lego.fabrictailor.network.payload.FabricTailorHelloPayload;
import org.samo_lego.fabrictailor.network.payload.HDSkinPayload;
import org.samo_lego.fabrictailor.network.payload.VanillaSkinPayload;

Expand Down Expand Up @@ -56,6 +57,8 @@ public void onInitialize() {

ServerConfigurationConnectionEvents.CONFIGURE.register(NetworkHandler::onConfigured);

PayloadTypeRegistry.configurationS2C().register(FabricTailorHelloPayload.TYPE, FabricTailorHelloPayload.CODEC);

PayloadTypeRegistry.playC2S().register(VanillaSkinPayload.TYPE, VanillaSkinPayload.CODEC);
ServerPlayNetworking.registerGlobalReceiver(VanillaSkinPayload.TYPE, NetworkHandler::changeVanillaSkinPacket);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.fabricmc.fabric.api.client.networking.v1.ClientConfigurationNetworking;
import net.fabricmc.fabric.api.client.networking.v1.ClientLoginConnectionEvents;
import net.fabricmc.fabric.api.networking.v1.PayloadTypeRegistry;
import net.minecraft.ChatFormatting;
import net.minecraft.client.KeyMapping;
import org.lwjgl.glfw.GLFW;
Expand Down Expand Up @@ -62,7 +61,6 @@ public void onInitializeClient() {
forceOpen = false;
});

PayloadTypeRegistry.configurationS2C().register(FabricTailorHelloPayload.TYPE, FabricTailorHelloPayload.CODEC);
ClientConfigurationNetworking.registerGlobalReceiver(FabricTailorHelloPayload.TYPE, (payload, context) -> {
TAILORED_SERVER = true;
ALLOW_DEFAULT_SKIN = payload.allowSkinButton();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@
import com.mojang.authlib.properties.Property;
import com.mojang.authlib.properties.PropertyMap;
import com.mojang.blaze3d.systems.RenderSystem;
import java.io.File;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
Expand All @@ -29,8 +23,6 @@
import org.joml.Quaternionf;
import org.joml.Vector3f;
import org.samo_lego.fabrictailor.casts.TailoredPlayer;
import static org.samo_lego.fabrictailor.client.ClientTailor.ALLOW_DEFAULT_SKIN;
import static org.samo_lego.fabrictailor.client.ClientTailor.TAILORED_SERVER;
import org.samo_lego.fabrictailor.client.screen.tabs.CapeTab;
import org.samo_lego.fabrictailor.client.screen.tabs.LocalSkinTab;
import org.samo_lego.fabrictailor.client.screen.tabs.PlayerSkinTab;
Expand All @@ -40,6 +32,16 @@
import org.samo_lego.fabrictailor.network.payload.DefaultSkinPayload;
import org.samo_lego.fabrictailor.util.TextTranslations;

import java.io.File;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;

import static org.samo_lego.fabrictailor.client.ClientTailor.ALLOW_DEFAULT_SKIN;
import static org.samo_lego.fabrictailor.client.ClientTailor.TAILORED_SERVER;

@Environment(EnvType.CLIENT)
public class SkinChangeScreen extends Screen {

Expand Down Expand Up @@ -146,7 +148,7 @@ protected void init() {
onClick -> {
var profile = ((AAbstractClientPlayer) this.minecraft.player).ft_getPlayerInfo().getProfile();

// could return empty collection, Iterator#next in this case produces NoSuchElementException
// could return an empty collection, Iterator#next in this case produces NoSuchElementException
Optional<Property> optionalProperty = profile.getProperties()
.get(TailoredPlayer.PROPERTY_TEXTURES)
.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import org.samo_lego.fabrictailor.util.TextTranslations;

import javax.imageio.ImageIO;
import java.awt.image.*;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.net.URI;
import java.net.URL;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public MServerPlayerEntity_TailoredPlayer(Level level, BlockPos blockPos, float

/**
* @author Pyrofab
* @see PlayerList#respawn(ServerPlayer, boolean)
* @see PlayerList#respawn(ServerPlayer, boolean, RemovalReason)
* <p>
* This method has been adapted from the Impersonate mod's <a href="https://github.com/Ladysnake/Impersonate/blob/1.16/src/main/java/io/github/ladysnake/impersonate/impl/ServerPlayerSkins.java">source code</a>
* under GNU Lesser General Public License.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,12 @@
import net.minecraft.client.Options;
import net.minecraft.client.gui.components.AbstractWidget;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.components.OptionsList;
import net.minecraft.client.gui.screens.OptionsSubScreen;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.screens.SkinCustomizationScreen;
import net.minecraft.network.chat.CommonComponents;
import net.minecraft.client.gui.screens.options.OptionsSubScreen;
import net.minecraft.client.gui.screens.options.SkinCustomizationScreen;
import net.minecraft.network.chat.Component;
import org.jetbrains.annotations.Nullable;
import org.samo_lego.fabrictailor.client.ClientTailor;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
Expand All @@ -22,13 +18,13 @@


@Mixin(SkinCustomizationScreen.class)
public class MSkinCustomizationScreen_SkinButton extends OptionsSubScreen {
public abstract class MSkinCustomizationScreen_SkinButton extends OptionsSubScreen {

public MSkinCustomizationScreen_SkinButton(Screen screen, Options options, Component component) {
super(screen, options, component);
}

@Inject(method = "init",
@Inject(method = "addOptions",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/gui/components/OptionsList;addSmall(Ljava/util/List;)V"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import static org.samo_lego.fabrictailor.FabricTailor.MOD_ID;

public class SkinPackets {
public static final ResourceLocation FABRICTAILOR_VANILLA_CHANGE = new ResourceLocation(MOD_ID, "skin_change_vanilla");
public static final ResourceLocation FABRICTAILOR_HD_CHANGE = new ResourceLocation(MOD_ID, "skin_change_hd");
public static final ResourceLocation FABRICTAILOR_DEFAULT_SKIN = new ResourceLocation(MOD_ID, "default_skin_request");
public static final ResourceLocation FT_HELLO = new ResourceLocation(MOD_ID, "hello");
public static final ResourceLocation FABRICTAILOR_VANILLA_CHANGE = ResourceLocation.fromNamespaceAndPath(MOD_ID, "skin_change_vanilla");
public static final ResourceLocation FABRICTAILOR_HD_CHANGE = ResourceLocation.fromNamespaceAndPath(MOD_ID, "skin_change_hd");
public static final ResourceLocation FABRICTAILOR_DEFAULT_SKIN = ResourceLocation.fromNamespaceAndPath(MOD_ID, "default_skin_request");
public static final ResourceLocation FT_HELLO = ResourceLocation.fromNamespaceAndPath(MOD_ID, "hello");
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

public record DefaultSkinPayload(Property skinProperty) implements CustomPacketPayload {

public static final Type<DefaultSkinPayload> TYPE = CustomPacketPayload.createType(FABRICTAILOR_DEFAULT_SKIN.toString());
public static final Type<DefaultSkinPayload> TYPE = new CustomPacketPayload.Type<>(FABRICTAILOR_DEFAULT_SKIN);
public static final StreamCodec<FriendlyByteBuf, DefaultSkinPayload> CODEC = StreamCodec.composite(PropertyExtension.STREAM_CODEC, DefaultSkinPayload::skinProperty, DefaultSkinPayload::new);

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

public record FabricTailorHelloPayload(boolean allowSkinButton) implements CustomPacketPayload {

public static final Type<FabricTailorHelloPayload> TYPE = CustomPacketPayload.createType(FT_HELLO.toString());
public static final Type<FabricTailorHelloPayload> TYPE = new CustomPacketPayload.Type<>(FT_HELLO);
public static final StreamCodec<FriendlyByteBuf, FabricTailorHelloPayload> CODEC = StreamCodec.of(
(buf, value) -> buf.writeBoolean(value.allowSkinButton()),
buf -> new FabricTailorHelloPayload(buf.readBoolean())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

public record HDSkinPayload(Property skinProperty) implements CustomPacketPayload {

public static final Type<HDSkinPayload> TYPE = CustomPacketPayload.createType(FABRICTAILOR_HD_CHANGE.toString());
public static final Type<HDSkinPayload> TYPE = new CustomPacketPayload.Type<>(FABRICTAILOR_HD_CHANGE);
public static final StreamCodec<FriendlyByteBuf, HDSkinPayload> CODEC = StreamCodec.composite(PropertyExtension.STREAM_CODEC, HDSkinPayload::skinProperty, HDSkinPayload::new);

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

public record VanillaSkinPayload(Property skinProperty) implements CustomPacketPayload {

public static final Type<VanillaSkinPayload> TYPE = CustomPacketPayload.createType(FABRICTAILOR_VANILLA_CHANGE.toString());
public static final Type<VanillaSkinPayload> TYPE = new CustomPacketPayload.Type<>(FABRICTAILOR_VANILLA_CHANGE);
public static final StreamCodec<FriendlyByteBuf, VanillaSkinPayload> CODEC = StreamCodec.composite(PropertyExtension.STREAM_CODEC, VanillaSkinPayload::skinProperty, VanillaSkinPayload::new);

@Override
Expand Down

0 comments on commit 14c0ae3

Please sign in to comment.