From 9b531cf0a252eec2c3f6fef422763559fcced9d1 Mon Sep 17 00:00:00 2001 From: tartaric_acid Date: Tue, 10 Dec 2024 00:00:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E6=89=93=E5=BC=80=E5=9D=90?= =?UTF-8?q?=E5=9E=AB=20GUI=20=E6=97=B6=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../touhoulittlemaid/entity/item/EntityChair.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/github/tartaricacid/touhoulittlemaid/entity/item/EntityChair.java b/src/main/java/com/github/tartaricacid/touhoulittlemaid/entity/item/EntityChair.java index dfd1fe20f..89f40a94c 100644 --- a/src/main/java/com/github/tartaricacid/touhoulittlemaid/entity/item/EntityChair.java +++ b/src/main/java/com/github/tartaricacid/touhoulittlemaid/entity/item/EntityChair.java @@ -6,7 +6,6 @@ import com.github.tartaricacid.touhoulittlemaid.config.subconfig.ChairConfig; import com.github.tartaricacid.touhoulittlemaid.init.InitItems; import com.github.tartaricacid.touhoulittlemaid.item.ItemChair; -import com.github.tartaricacid.touhoulittlemaid.network.NetworkHandler; import com.github.tartaricacid.touhoulittlemaid.network.message.OpenChairGuiPackage; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtUtils; @@ -15,6 +14,7 @@ import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.resources.ResourceKey; +import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundEvents; import net.minecraft.util.Mth; @@ -30,6 +30,7 @@ import net.neoforged.api.distmarker.Dist; import net.neoforged.api.distmarker.OnlyIn; import net.neoforged.fml.util.thread.EffectiveSide; +import net.neoforged.neoforge.network.PacketDistributor; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -110,8 +111,8 @@ public InteractionResult interact(Player player, InteractionHand hand) { if (player.getItemInHand(hand).interactLivingEntity(player, this, hand).consumesAction()) { return InteractionResult.SUCCESS; } - if (!level.isClientSide) { - NetworkHandler.sendToNearby(player, new OpenChairGuiPackage(getId())); + if (player instanceof ServerPlayer serverPlayer) { + PacketDistributor.sendToPlayer(serverPlayer, new OpenChairGuiPackage(getId())); } } else { if (!level.isClientSide && getPassengers().isEmpty() && !player.isPassenger()) {