更新内容

1. 修复玩偶在服务器导致崩溃的错误
This commit is contained in:
叁玖领域 2026-01-03 00:34:24 +08:00
parent 6a4a15c1f4
commit 97a232944b

View File

@ -13,6 +13,8 @@ import net.minecraft.nbt.NbtUtils;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import top.r3944realms.lib39.util.nbt.NBTReader; import top.r3944realms.lib39.util.nbt.NBTReader;
@ -31,10 +33,6 @@ public class GameProfileHelper {
public static final String TAG_BE = "BlockEntityTag"; public static final String TAG_BE = "BlockEntityTag";
public static final String TAG_OWN_PROFILE = "OwnerProfile"; public static final String TAG_OWN_PROFILE = "OwnerProfile";
/**
* The constant DEFAULT.
*/
public static ResourceLocation DEFAULT = DefaultPlayerSkin.getDefaultSkin();
/** /**
* Gets skin texture. * Gets skin texture.
@ -42,9 +40,10 @@ public class GameProfileHelper {
* @param gameProfile the game profile * @param gameProfile the game profile
* @return the skin texture * @return the skin texture
*/ */
@OnlyIn(Dist.CLIENT)
public static ResourceLocation getSkinTexture(@Nullable GameProfile gameProfile) { public static ResourceLocation getSkinTexture(@Nullable GameProfile gameProfile) {
if (gameProfile == null) { if (gameProfile == null) {
return DEFAULT; return DefaultPlayerSkin.getDefaultSkin();
} }
return resolveSkinTexture(gameProfile); return resolveSkinTexture(gameProfile);
} }
@ -55,6 +54,7 @@ public class GameProfileHelper {
* @param gameProfile the game profile * @param gameProfile the game profile
* @return the resource location * @return the resource location
*/ */
@OnlyIn(Dist.CLIENT)
public static @NotNull ResourceLocation resolveSkinTexture(@NotNull GameProfile gameProfile) { public static @NotNull ResourceLocation resolveSkinTexture(@NotNull GameProfile gameProfile) {
Minecraft minecraft = Minecraft.getInstance(); Minecraft minecraft = Minecraft.getInstance();
return minecraft.getSkinManager() return minecraft.getSkinManager()
@ -71,6 +71,7 @@ public class GameProfileHelper {
} }
// 客户端判断 // 客户端判断
@OnlyIn(Dist.CLIENT)
private static boolean hasSlimArmsClient(Player player) { private static boolean hasSlimArmsClient(Player player) {
if (player instanceof AbstractClientPlayer clientPlayer) { if (player instanceof AbstractClientPlayer clientPlayer) {
PlayerInfo playerInfo = Objects.requireNonNull(Minecraft.getInstance() PlayerInfo playerInfo = Objects.requireNonNull(Minecraft.getInstance()
@ -105,6 +106,7 @@ public class GameProfileHelper {
} }
// 获取皮肤模型名称 // 获取皮肤模型名称
@OnlyIn(Dist.CLIENT)
public static @NotNull String getSkinModelName(@NotNull Player player) { public static @NotNull String getSkinModelName(@NotNull Player player) {
if (player.level().isClientSide && player instanceof AbstractClientPlayer) { if (player.level().isClientSide && player instanceof AbstractClientPlayer) {
PlayerInfo info = Objects.requireNonNull(Minecraft.getInstance().getConnection()) PlayerInfo info = Objects.requireNonNull(Minecraft.getInstance().getConnection())