Paper/Spigot-Server-Patches/0107-Optional-TNT-doesn-t-move-in-water.patch
Spottedleaf 5c7081fecc Update upstream & fix some chunk related issues (#2177)
* Updated Upstream (Bukkit/CraftBukkit)

Upstream has released updates that appears to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
45690fe9 SPIGOT-5047: Correct slot types for 1.14 inventories

CraftBukkit Changes:
4090d01f SPIGOT-5047: Correct slot types for 1.14 inventories
e8c08362 SPIGOT-5046: World#getLoadedChunks returning inaccessible cached chunks.
d445af3b SPIGOT-5067: Add item meta for 1.14 spawn eggs

* Bring Chunk load checks in-line with spigot

As of the last upstream merge spigot now checks ticket level status
when returning loaded chunks for a world from api. Now our checks
will respect that decision.

* Fix spawn ticket levels

Vanilla would keep the inner chunks of spawn available for ticking,
however my changes made all chunks non-ticking. Resolve by changing
ticket levels for spawn chunks inside the border to respect this
behavior.


* Make World#getChunkIfLoadedImmediately return only entity ticking chunks

Mojang appears to be using chunks with level > 33 (non-ticking chunks)
as cached chunks and not actually loaded chunks.

* Bring all loaded checks in line with spigot

Loaded chunks must be at least border  chunks, or level <= 33
2019-06-14 03:27:40 +01:00

112 lines
4.5 KiB
Diff

From 1bac817fad6ad059f0b65e06887d5aea60364761 Mon Sep 17 00:00:00 2001
From: Zach Brown <zach.brown@destroystokyo.com>
Date: Sun, 22 May 2016 20:20:55 -0500
Subject: [PATCH] Optional TNT doesn't move in water
diff --git a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
index 805aa56999..92ab55182f 100644
--- a/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperWorldConfig.java
@@ -2,7 +2,6 @@ package com.destroystokyo.paper;
import java.util.List;
-import org.bukkit.Bukkit;
import org.bukkit.configuration.file.YamlConfiguration;
import org.spigotmc.SpigotWorldConfig;
@@ -287,4 +286,14 @@ public class PaperWorldConfig {
);
}
}
+
+ public boolean preventTntFromMovingInWater;
+ private void preventTntFromMovingInWater() {
+ if (PaperConfig.version < 13) {
+ boolean oldVal = getBoolean("enable-old-tnt-cannon-behaviors", false);
+ set("prevent-tnt-from-moving-in-water", oldVal);
+ }
+ preventTntFromMovingInWater = getBoolean("prevent-tnt-from-moving-in-water", false);
+ log("Prevent TNT from moving in water: " + preventTntFromMovingInWater);
+ }
}
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index 1cc7b9f60e..4ef333ef12 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -2645,6 +2645,12 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
}
public boolean bD() {
+ // Paper start
+ return this.pushedByWater();
+ }
+
+ public boolean pushedByWater() {
+ // Paper end
return true;
}
diff --git a/src/main/java/net/minecraft/server/EntityTNTPrimed.java b/src/main/java/net/minecraft/server/EntityTNTPrimed.java
index e0535604b6..baeb85142b 100644
--- a/src/main/java/net/minecraft/server/EntityTNTPrimed.java
+++ b/src/main/java/net/minecraft/server/EntityTNTPrimed.java
@@ -80,7 +80,27 @@ public class EntityTNTPrimed extends Entity {
this.ax();
this.world.addParticle(Particles.SMOKE, this.locX, this.locY + 0.5D, this.locZ, 0.0D, 0.0D, 0.0D);
}
-
+ // Paper start - Optional prevent TNT from moving in water
+ if (!this.dead && this.inWater && this.world.paperConfig.preventTntFromMovingInWater) {
+ /*
+ * Author: Jedediah Smith <jedediah@silencegreys.com>
+ */
+ // Send position and velocity updates to nearby players on every tick while the TNT is in water.
+ // This does pretty well at keeping their clients in sync with the server.
+ PlayerChunkMap.EntityTracker ete = this.tracker;
+ if (ete != null) {
+ PacketPlayOutEntityVelocity velocityPacket = new PacketPlayOutEntityVelocity(this);
+ PacketPlayOutEntityTeleport positionPacket = new PacketPlayOutEntityTeleport(this);
+
+ ete.trackedPlayers.stream()
+ .filter(viewer -> (viewer.locX - this.locX) * (viewer.locY - this.locY) * (viewer.locZ - this.locZ) < 16 * 16)
+ .forEach(viewer -> {
+ viewer.playerConnection.sendPacket(velocityPacket);
+ viewer.playerConnection.sendPacket(positionPacket);
+ });
+ }
+ }
+ // Paper end
}
private void explode() {
@@ -149,4 +169,11 @@ public class EntityTNTPrimed extends Entity {
public Packet<?> N() {
return new PacketPlayOutSpawnEntity(this);
}
+
+ // Paper start - Optional prevent TNT from moving in water
+ @Override
+ public boolean pushedByWater() {
+ return !world.paperConfig.preventTntFromMovingInWater && super.pushedByWater();
+ }
+ // Paper end
}
diff --git a/src/main/java/net/minecraft/server/EntityTrackerEntry.java b/src/main/java/net/minecraft/server/EntityTrackerEntry.java
index aaf3a54b08..afd8748da8 100644
--- a/src/main/java/net/minecraft/server/EntityTrackerEntry.java
+++ b/src/main/java/net/minecraft/server/EntityTrackerEntry.java
@@ -36,7 +36,7 @@ public class EntityTrackerEntry {
private boolean q;
private boolean r;
// CraftBukkit start
- private final Set<EntityPlayer> trackedPlayers;
+ final Set<EntityPlayer> trackedPlayers; // Paper - private -> package
// Paper start
private java.util.Map<EntityPlayer, Boolean> trackedPlayerMap = null;
--
2.21.0