pathfinding, packet utils

This commit is contained in:
Noah van der Aa 2024-12-13 18:56:07 +01:00
parent e20952c643
commit 18a25937bc
No known key found for this signature in database
GPG Key ID: 547D90BC6FF753CF
5 changed files with 18 additions and 35 deletions

View File

@ -1,8 +1,8 @@
--- a/net/minecraft/network/protocol/Packet.java --- a/net/minecraft/network/protocol/Packet.java
+++ b/net/minecraft/network/protocol/Packet.java +++ b/net/minecraft/network/protocol/Packet.java
@@ -11,6 +11,19 @@ @@ -11,6 +_,19 @@
void handle(T listener); void handle(T handler);
+ // Paper start + // Paper start
+ default boolean hasLargePacketFallback() { + default boolean hasLargePacketFallback() {

View File

@ -0,0 +1,10 @@
--- a/net/minecraft/network/protocol/PacketUtils.java
+++ b/net/minecraft/network/protocol/PacketUtils.java
@@ -21,6 +_,7 @@
public static <T extends PacketListener> void ensureRunningOnSameThread(Packet<T> packet, T processor, BlockableEventLoop<?> executor) throws RunningOnDifferentThreadException {
if (!executor.isSameThread()) {
executor.executeIfPossible(() -> {
+ if (processor instanceof net.minecraft.server.network.ServerCommonPacketListenerImpl serverCommonPacketListener && serverCommonPacketListener.processedDisconnect) return; // Paper - Don't handle sync packets for kicked players
if (processor.shouldHandleMessage(packet)) {
try {
packet.handle(processor);

View File

@ -1,10 +1,10 @@
--- a/net/minecraft/world/level/pathfinder/Path.java --- a/net/minecraft/world/level/pathfinder/Path.java
+++ b/net/minecraft/world/level/pathfinder/Path.java +++ b/net/minecraft/world/level/pathfinder/Path.java
@@ -18,6 +18,7 @@ @@ -18,6 +_,7 @@
private final BlockPos target; private final BlockPos target;
private final float distToTarget; private final float distToTarget;
private final boolean reached; private final boolean reached;
+ public boolean hasNext() { return getNextNodeIndex() < this.nodes.size(); } // Paper - Mob Pathfinding API + public boolean hasNext() { return getNextNodeIndex() < this.nodes.size(); } // Paper - Mob Pathfinding API
public Path(List<Node> nodes, BlockPos target, boolean reachesTarget) { public Path(List<Node> nodes, BlockPos target, boolean reached) {
this.nodes = nodes; this.nodes = nodes;

View File

@ -1,12 +1,12 @@
--- a/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java --- a/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java
+++ b/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java +++ b/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java
@@ -478,7 +478,12 @@ @@ -480,7 +_,12 @@
} }
protected static PathType getPathTypeFromState(BlockGetter world, BlockPos pos) { protected static PathType getPathTypeFromState(BlockGetter level, BlockPos pos) {
- BlockState blockState = world.getBlockState(pos); - BlockState blockState = level.getBlockState(pos);
+ // Paper start - Do not load chunks during pathfinding + // Paper start - Do not load chunks during pathfinding
+ BlockState blockState = world.getBlockStateIfLoaded(pos); + BlockState blockState = level.getBlockStateIfLoaded(pos);
+ if (blockState == null) { + if (blockState == null) {
+ return PathType.BLOCKED; + return PathType.BLOCKED;
+ } + }

View File

@ -1,27 +0,0 @@
--- a/net/minecraft/network/protocol/PacketUtils.java
+++ b/net/minecraft/network/protocol/PacketUtils.java
@@ -6,10 +6,15 @@
import net.minecraft.CrashReportCategory;
import net.minecraft.ReportedException;
import net.minecraft.network.PacketListener;
+import org.slf4j.Logger;
+
+// CraftBukkit start
+import net.minecraft.server.MinecraftServer;
import net.minecraft.server.RunningOnDifferentThreadException;
import net.minecraft.server.level.ServerLevel;
+import net.minecraft.server.network.ServerCommonPacketListenerImpl;
+// CraftBukkit end
import net.minecraft.util.thread.BlockableEventLoop;
-import org.slf4j.Logger;
public class PacketUtils {
@@ -24,6 +29,7 @@
public static <T extends PacketListener> void ensureRunningOnSameThread(Packet<T> packet, T listener, BlockableEventLoop<?> engine) throws RunningOnDifferentThreadException {
if (!engine.isSameThread()) {
engine.executeIfPossible(() -> {
+ if (listener instanceof ServerCommonPacketListenerImpl serverCommonPacketListener && serverCommonPacketListener.processedDisconnect) return; // CraftBukkit - Don't handle sync packets for kicked players
if (listener.shouldHandleMessage(packet)) {
try {
packet.handle(listener);