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
+++ b/net/minecraft/network/protocol/Packet.java
@@ -11,6 +11,19 @@
@@ -11,6 +_,19 @@
void handle(T listener);
void handle(T handler);
+ // Paper start
+ 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
+++ b/net/minecraft/world/level/pathfinder/Path.java
@@ -18,6 +18,7 @@
@@ -18,6 +_,7 @@
private final BlockPos target;
private final float distToTarget;
private final boolean reached;
+ 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;

View file

@ -1,12 +1,12 @@
--- a/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) {
- BlockState blockState = world.getBlockState(pos);
protected static PathType getPathTypeFromState(BlockGetter level, BlockPos pos) {
- BlockState blockState = level.getBlockState(pos);
+ // Paper start - Do not load chunks during pathfinding
+ BlockState blockState = world.getBlockStateIfLoaded(pos);
+ BlockState blockState = level.getBlockStateIfLoaded(pos);
+ if (blockState == null) {
+ 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);