pathfinding, packet utils
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
--- a/net/minecraft/network/protocol/Packet.java
|
||||
+++ b/net/minecraft/network/protocol/Packet.java
|
||||
@@ -11,6 +_,19 @@
|
||||
|
||||
void handle(T handler);
|
||||
|
||||
+ // Paper start
|
||||
+ default boolean hasLargePacketFallback() {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * override {@link #hasLargePacketFallback()} to return true when overriding in subclasses
|
||||
+ */
|
||||
+ default boolean packetTooLarge(net.minecraft.network.Connection manager) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
default boolean isSkippable() {
|
||||
return false;
|
||||
}
|
||||
@@ -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);
|
||||
@@ -0,0 +1,10 @@
|
||||
--- a/net/minecraft/world/level/pathfinder/Path.java
|
||||
+++ b/net/minecraft/world/level/pathfinder/Path.java
|
||||
@@ -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 reached) {
|
||||
this.nodes = nodes;
|
||||
@@ -0,0 +1,16 @@
|
||||
--- a/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java
|
||||
+++ b/net/minecraft/world/level/pathfinder/WalkNodeEvaluator.java
|
||||
@@ -480,7 +_,12 @@
|
||||
}
|
||||
|
||||
protected static PathType getPathTypeFromState(BlockGetter level, BlockPos pos) {
|
||||
- BlockState blockState = level.getBlockState(pos);
|
||||
+ // Paper start - Do not load chunks during pathfinding
|
||||
+ BlockState blockState = level.getBlockStateIfLoaded(pos);
|
||||
+ if (blockState == null) {
|
||||
+ return PathType.BLOCKED;
|
||||
+ }
|
||||
+ // Paper end
|
||||
Block block = blockState.getBlock();
|
||||
if (blockState.isAir()) {
|
||||
return PathType.OPEN;
|
||||
Reference in New Issue
Block a user