2018-08-06 01:46:43 +02:00
|
|
|
From 6d9962a0cf301943ff52739267c5c4435fad6fa4 Mon Sep 17 00:00:00 2001
|
2017-05-14 20:05:01 +02:00
|
|
|
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
|
2018-08-06 01:46:43 +02:00
|
|
|
index a3823408ca..41e73b3409 100644
|
2017-05-14 20:05:01 +02:00
|
|
|
--- 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;
|
|
|
|
|
2018-07-24 02:24:44 +02:00
|
|
|
@@ -276,4 +275,14 @@ public class PaperWorldConfig {
|
2017-05-14 20:05:01 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ 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
|
2018-08-06 01:46:43 +02:00
|
|
|
index 428eaca37a..964caa080c 100644
|
2017-05-14 20:05:01 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/Entity.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/Entity.java
|
2018-07-31 03:19:41 +02:00
|
|
|
@@ -1173,6 +1173,12 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
2017-05-14 20:05:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean aq() {
|
2018-07-16 17:34:55 +02:00
|
|
|
+ // Paper start
|
2017-05-14 20:05:01 +02:00
|
|
|
+ return this.doWaterMovement();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public boolean doWaterMovement() {
|
|
|
|
+ // Paper end
|
2018-07-16 17:34:55 +02:00
|
|
|
return this.isInWater() || this.q();
|
2017-05-14 20:05:01 +02:00
|
|
|
}
|
|
|
|
|
2018-07-31 03:19:41 +02:00
|
|
|
@@ -2726,6 +2732,11 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
2018-07-16 17:34:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean bw() {
|
2017-05-14 20:05:01 +02:00
|
|
|
+ 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
|
2018-08-06 01:46:43 +02:00
|
|
|
index 87f3205f82..8c1d25979f 100644
|
2017-05-14 20:05:01 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/EntityTNTPrimed.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/EntityTNTPrimed.java
|
2017-05-15 17:28:28 +02:00
|
|
|
@@ -147,4 +147,49 @@ public class EntityTNTPrimed extends Entity {
|
2017-05-14 20:05:01 +02:00
|
|
|
public int getFuseTicks() {
|
|
|
|
return this.c;
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ // Paper start - Optional prevent TNT from moving in water
|
|
|
|
+ @Override
|
|
|
|
+ public boolean pushedByWater() {
|
|
|
|
+ return !world.paperConfig.preventTntFromMovingInWater && super.pushedByWater();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Author: Jedediah Smith <jedediah@silencegreys.com>
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public boolean doWaterMovement() {
|
|
|
|
+ if (!world.paperConfig.preventTntFromMovingInWater) return super.doWaterMovement();
|
|
|
|
+
|
|
|
|
+ // Preserve velocity while calling the super method
|
|
|
|
+ double oldMotX = this.motX;
|
|
|
|
+ double oldMotY = this.motY;
|
|
|
|
+ double oldMotZ = this.motZ;
|
|
|
|
+
|
|
|
|
+ super.doWaterMovement();
|
|
|
|
+
|
|
|
|
+ this.motX = oldMotX;
|
|
|
|
+ this.motY = oldMotY;
|
|
|
|
+ this.motZ = oldMotZ;
|
|
|
|
+
|
|
|
|
+ if (this.inWater) {
|
|
|
|
+ // 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.
|
|
|
|
+ EntityTrackerEntry ete = ((WorldServer) this.getWorld()).getTracker().trackedEntities.get(this.getId());
|
|
|
|
+ if (ete != null) {
|
|
|
|
+ PacketPlayOutEntityVelocity velocityPacket = new PacketPlayOutEntityVelocity(this);
|
|
|
|
+ PacketPlayOutEntityTeleport positionPacket = new PacketPlayOutEntityTeleport(this);
|
|
|
|
+
|
2017-05-15 17:28:28 +02:00
|
|
|
+ ete.trackedPlayers.stream()
|
|
|
|
+ .filter(viewer -> (viewer.locX - this.locX) * (viewer.locY - this.locY) * (viewer.locZ - this.locZ) < 16 * 16)
|
|
|
|
+ .forEach(viewer -> {
|
2017-05-14 20:05:01 +02:00
|
|
|
+ viewer.playerConnection.sendPacket(velocityPacket);
|
|
|
|
+ viewer.playerConnection.sendPacket(positionPacket);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return this.inWater;
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
--
|
2018-08-06 01:46:43 +02:00
|
|
|
2.18.0
|
2017-05-14 20:05:01 +02:00
|
|
|
|