mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 07:20:24 +01:00
Fix "prevent players from moving into unloaded chunks"
it used public method instead of private, and moved to world config also improved the implementation to not use obfuscated stuff Also removed the Fix Double chest conversion patch since its fixed in other ways in vanilla
This commit is contained in:
parent
0e5039cd83
commit
ebeba451f2
3 changed files with 23 additions and 76 deletions
|
@ -5,17 +5,17 @@ Subject: [PATCH] Add option to prevent players from moving into unloaded
|
|||
chunks #1551
|
||||
|
||||
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
||||
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||
index 7ac07ac07ac0..7ac07ac07ac0 100644
|
||||
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
||||
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
|
||||
@@ -0,0 +0,0 @@ public class PaperConfig {
|
||||
velocitySecretKey = secret.getBytes(StandardCharsets.UTF_8);
|
||||
}
|
||||
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
|
||||
@@ -0,0 +0,0 @@ public class PaperWorldConfig {
|
||||
replacementBlocks = getList("anti-xray.replacement-blocks", Arrays.asList("stone", "planks"));
|
||||
log("Anti-Xray: " + (antiXray ? "enabled" : "disabled") + " / Engine Mode: " + engineMode.getDescription() + " / Chunk Edge Mode: " + chunkEdgeMode.getDescription() + " / Up to " + ((maxChunkSectionIndex + 1) * 16) + " blocks / Update Radius: " + updateRadius);
|
||||
}
|
||||
+
|
||||
+ public static boolean preventMovingIntoUnloadedChunks = false;
|
||||
+ public static void preventMovingIntoUnloadedChunks() {
|
||||
+ public boolean preventMovingIntoUnloadedChunks = false;
|
||||
+ private void preventMovingIntoUnloadedChunks() {
|
||||
+ preventMovingIntoUnloadedChunks = getBoolean("settings.prevent-moving-into-unloaded-chunks", false);
|
||||
+ }
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ index 7ac07ac07ac0..7ac07ac07ac0 100644
|
|||
speed *= 2f; // TODO: Get the speed of the vehicle instead of the player
|
||||
|
||||
+ // Paper start - Prevent moving into unloaded chunks
|
||||
+ if(com.destroystokyo.paper.PaperConfig.preventMovingIntoUnloadedChunks && !worldserver.isChunkLoaded((int) Math.floor(d4) >> 4, (int) Math.floor(d6) >> 4, false)) {
|
||||
+ if (player.world.paperConfig.preventMovingIntoUnloadedChunks && !worldserver.isChunkLoaded((int) Math.floor(packetplayinvehiclemove.getX()) >> 4, (int) Math.floor(packetplayinvehiclemove.getZ()) >> 4, false)) {
|
||||
+ this.networkManager.sendPacket(new PacketPlayOutVehicleMove(entity));
|
||||
+ return;
|
||||
+ }
|
||||
|
@ -37,12 +37,24 @@ index 7ac07ac07ac0..7ac07ac07ac0 100644
|
|||
if (d10 - d9 > Math.max(100.0D, Math.pow((double) (org.spigotmc.SpigotConfig.movedTooQuicklyMultiplier * (float) i * speed), 2)) && (!this.minecraftServer.H() || !this.minecraftServer.G().equals(entity.getDisplayName().getString()))) {
|
||||
// CraftBukkit end
|
||||
PlayerConnection.LOGGER.warn("{} (vehicle of {}) moved too quickly! {},{},{}", entity.getDisplayName().getString(), this.player.getDisplayName().getString(), Double.valueOf(d6), Double.valueOf(d7), Double.valueOf(d8));
|
||||
@@ -0,0 +0,0 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
|
||||
double d1 = this.player.locY;
|
||||
double d2 = this.player.locZ;
|
||||
double d3 = this.player.locY;
|
||||
- double d4 = packetplayinflying.a(this.player.locX);
|
||||
+ double d4 = packetplayinflying.a(this.player.locX);double toX = d4; // Paper - OBFHELPER
|
||||
double d5 = packetplayinflying.b(this.player.locY);
|
||||
- double d6 = packetplayinflying.c(this.player.locZ);
|
||||
+ double d6 = packetplayinflying.c(this.player.locZ);double toZ = d6; // Paper - OBFHELPER
|
||||
float f = packetplayinflying.a(this.player.yaw);
|
||||
float f1 = packetplayinflying.b(this.player.pitch);
|
||||
double d7 = d4 - this.l;
|
||||
@@ -0,0 +0,0 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
|
||||
speed = player.abilities.walkSpeed * 10f;
|
||||
}
|
||||
|
||||
+ // Paper start - Prevent moving into unloaded chunks
|
||||
+ if(com.destroystokyo.paper.PaperConfig.preventMovingIntoUnloadedChunks && !worldserver.isChunkLoaded((int) Math.floor(d4) >> 4, (int) Math.floor(d6) >> 4, false)) {
|
||||
+ if (player.world.paperConfig.preventMovingIntoUnloadedChunks && (this.player.locX != toX || this.player.locZ != toZ) && !worldserver.isChunkLoaded((int) Math.floor(toX) >> 4, (int) Math.floor(toZ) >> 4, false)) {
|
||||
+ this.internalTeleport(this.player.locX, this.player.locY, this.player.locZ, this.player.yaw, this.player.pitch, Collections.emptySet());
|
||||
+ return;
|
||||
+ }
|
||||
|
|
|
@ -1,65 +0,0 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Thu, 20 Sep 2018 19:11:33 -0400
|
||||
Subject: [PATCH] MC-134115: Fix Double Chest Conversion Error
|
||||
|
||||
A bug with double chest conversion would lead to data
|
||||
loss from chunks if they crossed chunk boundries.
|
||||
|
||||
This fixes the issue.
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
|
||||
index 7ac07ac07ac0..7ac07ac07ac0 100644
|
||||
--- a/src/main/java/net/minecraft/server/Chunk.java
|
||||
+++ b/src/main/java/net/minecraft/server/Chunk.java
|
||||
@@ -0,0 +0,0 @@ public class Chunk implements IChunkAccess {
|
||||
return this.setType(blockposition, iblockdata, flag, true);
|
||||
}
|
||||
|
||||
+ // Paper start
|
||||
+ public void setTypeDirect(BlockPosition blockposition, IBlockData iblockdata) {
|
||||
+ int i = blockposition.getX() & 15;
|
||||
+ int j = blockposition.getY();
|
||||
+ int k = blockposition.getZ() & 15;
|
||||
+ ChunkSection section = this.sections[j >> 4];
|
||||
+
|
||||
+ if (section == Chunk.EMPTY_CHUNK_SECTION) {
|
||||
+ if (iblockdata.isAir()) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ section = new ChunkSection(j >> 4 << 4, this.world.worldProvider.g(), this, this.world, true); // Paper - Anti-Xray
|
||||
+ this.sections[j >> 4] = section;
|
||||
+ }
|
||||
+
|
||||
+ section.setType(i, j & 15, k, iblockdata);
|
||||
+ }
|
||||
+ // Paper end
|
||||
+
|
||||
@Nullable
|
||||
public IBlockData setType(BlockPosition blockposition, IBlockData iblockdata, boolean flag, boolean doPlace) {
|
||||
// CraftBukkit end
|
||||
diff --git a/src/main/java/net/minecraft/server/ChunkConverter.java b/src/main/java/net/minecraft/server/ChunkConverter.java
|
||||
index 7ac07ac07ac0..7ac07ac07ac0 100644
|
||||
--- a/src/main/java/net/minecraft/server/ChunkConverter.java
|
||||
+++ b/src/main/java/net/minecraft/server/ChunkConverter.java
|
||||
@@ -0,0 +0,0 @@ public class ChunkConverter {
|
||||
EnumDirection enumdirection1 = (EnumDirection)iblockdata.get(BlockChest.FACING);
|
||||
if (enumdirection.k() != enumdirection1.k() && enumdirection1 == iblockdata1.get(BlockChest.FACING)) {
|
||||
BlockPropertyChestType blockpropertychesttype = enumdirection == enumdirection1.e() ? BlockPropertyChestType.LEFT : BlockPropertyChestType.RIGHT;
|
||||
- generatoraccess.setTypeAndData(blockposition1, (IBlockData)iblockdata1.set(BlockChest.b, blockpropertychesttype.a()), 18);
|
||||
+ // Paper start
|
||||
+ Chunk chunk = ((World) generatoraccess.getMinecraftWorld()).getChunkAtWorldCoords(blockposition);
|
||||
+ Chunk chunk1 = ((World) generatoraccess.getMinecraftWorld()).getChunkAtWorldCoords(blockposition1);
|
||||
+ chunk1.setTypeDirect(blockposition1, (IBlockData)iblockdata1.set(BlockChest.b, blockpropertychesttype.a()));
|
||||
+
|
||||
if (enumdirection1 == EnumDirection.NORTH || enumdirection1 == EnumDirection.EAST) {
|
||||
- TileEntity tileentity = generatoraccess.getTileEntity(blockposition);
|
||||
- TileEntity tileentity1 = generatoraccess.getTileEntity(blockposition1);
|
||||
+ TileEntity tileentity = chunk.getTileEntity(blockposition);
|
||||
+ TileEntity tileentity1 = chunk1.getTileEntity(blockposition1);
|
||||
+ // Paper end
|
||||
if (tileentity instanceof TileEntityChest && tileentity1 instanceof TileEntityChest) {
|
||||
TileEntityChest.a((TileEntityChest)tileentity, (TileEntityChest)tileentity1);
|
||||
}
|
||||
--
|
|
@ -20,7 +20,7 @@ think of no reason to use it.
|
|||
Fixes GH-1571
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/TileEntitySign.java b/src/main/java/net/minecraft/server/TileEntitySign.java
|
||||
index 20dc3f272..3c712fc93 100644
|
||||
index 7ac07ac07ac0..7ac07ac07ac0 100644
|
||||
--- a/src/main/java/net/minecraft/server/TileEntitySign.java
|
||||
+++ b/src/main/java/net/minecraft/server/TileEntitySign.java
|
||||
@@ -0,0 +0,0 @@ public class TileEntitySign extends TileEntity implements ICommandListener {
|
||||
|
|
Loading…
Reference in a new issue