From 38a1ce044362774981efc41d4e2f6494bd2edccb Mon Sep 17 00:00:00 2001 From: Helvetica Volubi Date: Wed, 26 Nov 2025 22:31:47 +0800 Subject: [PATCH] fix: fix crash caused by uncheck data access --- gradle.properties | 2 +- .../leaves/protocol/servux/ServuxEntityDataProtocol.java | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 4bbad23..df16c59 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,7 +4,7 @@ mcVersion=1.21.8 release=2 # 0 for skip release, 1 for pre-release, 2 for release -luminolRef=774ad06b2b18e2ac1063a27e0f152484da210843 +luminolRef=b025236498b7e18c489f97a97587d7e0b5214de4 org.gradle.configuration-cache=true org.gradle.caching=true diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/servux/ServuxEntityDataProtocol.java b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/servux/ServuxEntityDataProtocol.java index def785d..40f6c0f 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/protocol/servux/ServuxEntityDataProtocol.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/protocol/servux/ServuxEntityDataProtocol.java @@ -17,6 +17,7 @@ package org.leavesmc.leaves.protocol.servux; +import ca.spottedleaf.moonrise.common.util.TickThread; import com.mojang.logging.LogUtils; import fun.bm.lophine.config.modules.function.protocol.ServuxProtocolConfig; import io.netty.buffer.Unpooled; @@ -31,6 +32,7 @@ import net.minecraft.util.RandomSource; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.phys.Vec3; import org.leavesmc.leaves.protocol.core.LeavesCustomPayload; import org.leavesmc.leaves.protocol.core.LeavesProtocol; import org.leavesmc.leaves.protocol.core.ProtocolHandler; @@ -104,6 +106,7 @@ public class ServuxEntityDataProtocol implements LeavesProtocol { public static void onBlockEntityRequest(ServerPlayer player, BlockPos pos) { player.getBukkitEntity().taskScheduler.schedule((LivingEntity nmsEntity) -> { + if (!TickThread.isTickThreadFor(nmsEntity.level(), pos)) return; BlockEntity be = nmsEntity.level().getBlockEntity(pos); CompoundTag nbt = be != null ? be.saveWithFullMetadata(nmsEntity.registryAccess()) : new CompoundTag(); @@ -115,7 +118,9 @@ public class ServuxEntityDataProtocol implements LeavesProtocol { } public static void onEntityRequest(ServerPlayer player, int entityId) { + final Vec3 pos = player.position(); player.getBukkitEntity().taskScheduler.schedule((LivingEntity nmsEntity) -> { + if (!TickThread.isTickThreadFor(nmsEntity.level(), pos)) return; Entity entity = nmsEntity.level().getEntity(entityId); CompoundTag nbt = TagUtil.saveEntityWithoutId(entity);