2020-05-06 11:48:49 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2019-07-20 06:01:24 +02:00
|
|
|
From: Shane Freeder <theboyetronic@gmail.com>
|
|
|
|
Date: Sun, 11 Nov 2018 21:01:09 +0000
|
|
|
|
Subject: [PATCH] Don't allow digging into unloaded chunks
|
|
|
|
|
|
|
|
|
2021-03-16 08:19:45 +01:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/level/PlayerInteractManager.java b/src/main/java/net/minecraft/server/level/PlayerInteractManager.java
|
2021-04-27 17:51:42 +02:00
|
|
|
index 14f287d30c9a141f78f6311bef02a6fc4fa17564..d86b1e528b53db809ac993aa2f1d2799d4f1a574 100644
|
2021-03-16 08:19:45 +01:00
|
|
|
--- a/src/main/java/net/minecraft/server/level/PlayerInteractManager.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/level/PlayerInteractManager.java
|
2021-04-27 17:51:42 +02:00
|
|
|
@@ -114,8 +114,8 @@ public class PlayerInteractManager {
|
2020-05-23 00:57:48 +02:00
|
|
|
IBlockData iblockdata;
|
|
|
|
|
2020-06-25 16:09:55 +02:00
|
|
|
if (this.j) {
|
|
|
|
- iblockdata = this.world.getType(this.k);
|
2020-05-23 00:57:48 +02:00
|
|
|
- if (iblockdata.isAir()) {
|
2020-06-25 16:09:55 +02:00
|
|
|
+ iblockdata = this.world.getTypeIfLoaded(this.k); // Paper
|
2020-05-23 00:57:48 +02:00
|
|
|
+ if (iblockdata == null || iblockdata.isAir()) { // Paper
|
2020-06-25 16:09:55 +02:00
|
|
|
this.j = false;
|
2020-05-23 00:57:48 +02:00
|
|
|
} else {
|
2020-06-25 16:09:55 +02:00
|
|
|
float f = this.a(iblockdata, this.k, this.l);
|
2021-04-27 17:51:42 +02:00
|
|
|
@@ -126,7 +126,13 @@ public class PlayerInteractManager {
|
2020-05-23 00:57:48 +02:00
|
|
|
}
|
|
|
|
}
|
2020-06-25 16:09:55 +02:00
|
|
|
} else if (this.f) {
|
|
|
|
- iblockdata = this.world.getType(this.h);
|
2020-05-23 00:57:48 +02:00
|
|
|
+ // Paper start - don't want to do same logic as above, return instead
|
2020-06-25 16:09:55 +02:00
|
|
|
+ iblockdata = this.world.getTypeIfLoaded(this.h);
|
2020-05-23 00:57:48 +02:00
|
|
|
+ if (iblockdata == null) {
|
2020-06-25 16:09:55 +02:00
|
|
|
+ this.f = false;
|
2020-05-23 00:57:48 +02:00
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
if (iblockdata.isAir()) {
|
2020-06-25 16:09:55 +02:00
|
|
|
this.world.a(this.player.getId(), this.h, -1);
|
|
|
|
this.m = -1;
|
2021-04-27 17:51:42 +02:00
|
|
|
@@ -290,10 +296,12 @@ public class PlayerInteractManager {
|
2020-04-13 05:56:29 +02:00
|
|
|
this.player.playerConnection.sendPacket(new PacketPlayOutBlockBreak(blockposition, this.world.getType(blockposition), packetplayinblockdig_enumplayerdigtype, true, "stopped destroying"));
|
|
|
|
} else if (packetplayinblockdig_enumplayerdigtype == PacketPlayInBlockDig.EnumPlayerDigType.ABORT_DESTROY_BLOCK) {
|
2020-06-25 16:09:55 +02:00
|
|
|
this.f = false;
|
|
|
|
- if (!Objects.equals(this.h, blockposition)) {
|
|
|
|
+ if (!Objects.equals(this.h, blockposition) && !BlockPosition.ZERO.equals(this.h)) {
|
|
|
|
PlayerInteractManager.LOGGER.debug("Mismatch in destroy block pos: " + this.h + " " + blockposition); // CraftBukkit - SPIGOT-5457 sent by client when interact event cancelled
|
|
|
|
- this.world.a(this.player.getId(), this.h, -1);
|
|
|
|
- this.player.playerConnection.sendPacket(new PacketPlayOutBlockBreak(this.h, this.world.getType(this.h), packetplayinblockdig_enumplayerdigtype, true, "aborted mismatched destroying"));
|
|
|
|
+ IBlockData type = this.world.getTypeIfLoaded(this.h); // Paper - don't load unloaded chunks for stale records here
|
|
|
|
+ if (type != null) this.world.a(this.player.getId(), this.h, -1); // Paper
|
|
|
|
+ if (type != null) this.player.playerConnection.sendPacket(new PacketPlayOutBlockBreak(this.h, type, packetplayinblockdig_enumplayerdigtype, true, "aborted mismatched destroying")); // Paper
|
|
|
|
+ this.h = BlockPosition.ZERO; // Paper
|
2020-04-13 05:56:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
this.world.a(this.player.getId(), blockposition, -1);
|
2021-03-16 08:19:45 +01:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/network/PlayerConnection.java b/src/main/java/net/minecraft/server/network/PlayerConnection.java
|
2021-04-18 11:02:48 +02:00
|
|
|
index 69b27924b8f12b647133fedcfb0568698d19f413..59617fceecb08edf665902f30ea7064e6333bb96 100644
|
2021-03-16 08:19:45 +01:00
|
|
|
--- a/src/main/java/net/minecraft/server/network/PlayerConnection.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/network/PlayerConnection.java
|
2021-04-18 11:02:48 +02:00
|
|
|
@@ -1519,6 +1519,11 @@ public class PlayerConnection implements PacketListenerPlayIn {
|
2021-03-16 08:19:45 +01:00
|
|
|
case START_DESTROY_BLOCK:
|
|
|
|
case ABORT_DESTROY_BLOCK:
|
|
|
|
case STOP_DESTROY_BLOCK:
|
|
|
|
+ // Paper start - Don't allow digging in unloaded chunks
|
|
|
|
+ if (this.player.world.getChunkIfLoadedImmediately(blockposition.getX() >> 4, blockposition.getZ() >> 4) == null) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // Paper end - Don't allow digging in unloaded chunks
|
|
|
|
this.player.playerInteractManager.a(blockposition, packetplayinblockdig_enumplayerdigtype, packetplayinblockdig.c(), this.minecraftServer.getMaxBuildHeight());
|
|
|
|
return;
|
|
|
|
default:
|