mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 12:27:59 +01:00
pathfinding, packet utils
This commit is contained in:
parent
e20952c643
commit
18a25937bc
@ -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() {
|
@ -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);
|
@ -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;
|
@ -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;
|
||||||
+ }
|
+ }
|
@ -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);
|
|
Loading…
Reference in New Issue
Block a user