2019-05-08 01:13:24 +00:00
|
|
|
From 530d6b6635e21f94b2334b735f3c773ce70a947c Mon Sep 17 00:00:00 2001
|
2017-05-14 18:05:01 +00: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
|
2019-05-06 00:57:14 +00:00
|
|
|
index 805aa56999..92ab55182f 100644
|
2017-05-14 18:05:01 +00: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;
|
|
|
|
|
2019-04-27 06:26:04 +00:00
|
|
|
@@ -287,4 +286,14 @@ public class PaperWorldConfig {
|
2017-05-14 18:05:01 +00: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
|
2019-05-06 02:58:04 +00:00
|
|
|
index 2f4e56fc56..2f1cd47619 100644
|
2017-05-14 18:05:01 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/Entity.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/Entity.java
|
2019-05-06 02:58:04 +00:00
|
|
|
@@ -107,7 +107,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
2019-05-06 00:57:14 +00:00
|
|
|
public double locX;
|
|
|
|
public double locY;
|
|
|
|
public double locZ;
|
|
|
|
- private Vec3D mot;
|
|
|
|
+ protected Vec3D mot; // Paper - private -> protected
|
|
|
|
public float yaw;
|
|
|
|
public float pitch;
|
|
|
|
public float lastYaw;
|
2019-05-06 02:58:04 +00:00
|
|
|
@@ -1103,6 +1103,12 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
2017-05-14 18:05:01 +00:00
|
|
|
}
|
|
|
|
|
2019-04-27 06:26:04 +00:00
|
|
|
public boolean au() {
|
2018-07-16 15:34:55 +00:00
|
|
|
+ // Paper start
|
2017-05-14 18:05:01 +00:00
|
|
|
+ return this.doWaterMovement();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public boolean doWaterMovement() {
|
|
|
|
+ // Paper end
|
2019-04-27 06:26:04 +00:00
|
|
|
return this.isInWater() || this.l();
|
2017-05-14 18:05:01 +00:00
|
|
|
}
|
|
|
|
|
2019-05-06 02:58:04 +00:00
|
|
|
@@ -2640,6 +2646,12 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
2018-07-16 15:34:55 +00:00
|
|
|
}
|
|
|
|
|
2019-04-27 06:26:04 +00:00
|
|
|
public boolean bD() {
|
|
|
|
+ // Paper start
|
2017-05-14 18:05:01 +00: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
|
2019-05-08 01:13:24 +00:00
|
|
|
index e0535604b6..723ed45d5e 100644
|
2017-05-14 18:05:01 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/EntityTNTPrimed.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/EntityTNTPrimed.java
|
2019-05-06 00:57:14 +00:00
|
|
|
@@ -149,4 +149,50 @@ public class EntityTNTPrimed extends Entity {
|
2019-04-27 06:26:04 +00:00
|
|
|
public Packet<?> N() {
|
|
|
|
return new PacketPlayOutSpawnEntity(this);
|
2017-05-14 18:05:01 +00:00
|
|
|
}
|
|
|
|
+
|
|
|
|
+ // 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
|
2019-05-06 00:57:14 +00:00
|
|
|
+ // TODO test this patch...
|
|
|
|
+// double oldMotX = this.motX;
|
|
|
|
+// double oldMotY = this.motY;
|
|
|
|
+// double oldMotZ = this.motZ;
|
|
|
|
+//
|
|
|
|
+// super.doWaterMovement();
|
|
|
|
+//
|
|
|
|
+// this.motX = oldMotX;
|
|
|
|
+// this.motY = oldMotY;
|
|
|
|
+// this.motZ = oldMotZ;
|
2017-05-14 18:05:01 +00:00
|
|
|
+
|
|
|
|
+ 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.
|
2019-05-08 01:13:24 +00:00
|
|
|
+ PlayerChunkMap.EntityTracker ete = this.tracker; // TODO review this (this field isn't written to)
|
2017-05-14 18:05:01 +00:00
|
|
|
+ if (ete != null) {
|
|
|
|
+ PacketPlayOutEntityVelocity velocityPacket = new PacketPlayOutEntityVelocity(this);
|
|
|
|
+ PacketPlayOutEntityTeleport positionPacket = new PacketPlayOutEntityTeleport(this);
|
|
|
|
+
|
2017-05-15 15:28:28 +00: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 18:05:01 +00:00
|
|
|
+ viewer.playerConnection.sendPacket(velocityPacket);
|
|
|
|
+ viewer.playerConnection.sendPacket(positionPacket);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return this.inWater;
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
}
|
2019-05-06 00:57:14 +00:00
|
|
|
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;
|
|
|
|
|
2017-05-14 18:05:01 +00:00
|
|
|
--
|
2019-03-05 05:46:37 +00:00
|
|
|
2.21.0
|
2017-05-14 18:05:01 +00:00
|
|
|
|