Skip to content

Commit

Permalink
修正打开坐垫 GUI 时的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
TartaricAcid committed Dec 9, 2024
1 parent ba38c7e commit 9b531cf
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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()) {
Expand Down

0 comments on commit 9b531cf

Please sign in to comment.