mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-25 09:59:20 +00:00
修复folia
This commit is contained in:
@@ -317,7 +317,17 @@ public class BukkitServerPlayer extends Player {
|
||||
public void tick() {
|
||||
// not fully online
|
||||
if (serverPlayer() == null) return;
|
||||
this.gameTicks = FastNMS.INSTANCE.field$MinecraftServer$currentTick();
|
||||
if (VersionHelper.isFolia()) {
|
||||
try {
|
||||
Object serverPlayer = serverPlayer();
|
||||
Object gameMode = Reflections.field$ServerPlayer$gameMode.get(serverPlayer);
|
||||
this.gameTicks = (int) Reflections.field$ServerPlayerGameMode$gameTicks.get(gameMode);
|
||||
} catch (ReflectiveOperationException e) {
|
||||
CraftEngine.instance().logger().warn("Failed to get game tick for " + name(), e);
|
||||
}
|
||||
} else {
|
||||
this.gameTicks = FastNMS.INSTANCE.field$MinecraftServer$currentTick();
|
||||
}
|
||||
if (this.isDestroyingBlock) {
|
||||
this.tickBlockDestroy();
|
||||
}
|
||||
|
||||
@@ -2919,11 +2919,11 @@ public class Reflections {
|
||||
)
|
||||
);
|
||||
|
||||
// public static final Field field$ServerPlayer$gameMode = requireNonNull(
|
||||
// ReflectionUtils.getDeclaredField(
|
||||
// clazz$ServerPlayer, clazz$ServerPlayerGameMode, 0
|
||||
// )
|
||||
// );
|
||||
public static final Field field$ServerPlayer$gameMode = requireNonNull(
|
||||
ReflectionUtils.getDeclaredField(
|
||||
clazz$ServerPlayer, clazz$ServerPlayerGameMode, 0
|
||||
)
|
||||
);
|
||||
|
||||
public static final Field field$ServerPlayerGameMode$destroyProgressStart = requireNonNull(
|
||||
ReflectionUtils.getDeclaredField(
|
||||
@@ -2931,11 +2931,11 @@ public class Reflections {
|
||||
)
|
||||
);
|
||||
|
||||
// public static final Field field$ServerPlayerGameMode$gameTicks = requireNonNull(
|
||||
// ReflectionUtils.getDeclaredField(
|
||||
// clazz$ServerPlayerGameMode, int.class, 1
|
||||
// )
|
||||
// );
|
||||
public static final Field field$ServerPlayerGameMode$gameTicks = requireNonNull(
|
||||
ReflectionUtils.getDeclaredField(
|
||||
clazz$ServerPlayerGameMode, int.class, 1
|
||||
)
|
||||
);
|
||||
|
||||
public static final Field field$ServerPlayerGameMode$delayedTickStart = requireNonNull(
|
||||
ReflectionUtils.getDeclaredField(
|
||||
|
||||
Reference in New Issue
Block a user