2020-05-06 09:48:49 +00:00
|
|
|
From 0000000000000000000000000000000000000000 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
|
2021-01-11 01:44:06 +00:00
|
|
|
index eb04fdb172a50ec1f5b7fe78fa0e7655246abd60..6eca3f300020006f02dd36253b522db442e3cc33 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;
|
|
|
|
|
2021-01-11 01:44:06 +00:00
|
|
|
@@ -291,4 +290,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
|
2021-02-21 19:45:33 +00:00
|
|
|
index df6377b5849aab20246a29b312744604b4cbf6bf..7abe7bcddd3c60bfb0f290e2475d28396d5319cf 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
|
2021-01-11 01:44:06 +00:00
|
|
|
@@ -2681,6 +2681,11 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
2018-07-16 15:34:55 +00:00
|
|
|
}
|
|
|
|
|
2020-11-03 02:22:15 +00:00
|
|
|
public boolean bV() {
|
2019-04-27 06:26:04 +00:00
|
|
|
+ // 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
|
2020-11-03 02:22:15 +00:00
|
|
|
index e25404fd89ad6317c2656c68c2e32aa05e5f0e73..b108874d977a4fb1a7c0d52f66bc08390decb4d0 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
|
2020-04-08 07:49:15 +00:00
|
|
|
@@ -80,7 +80,27 @@ public class EntityTNTPrimed extends Entity {
|
2019-12-11 23:43:22 +00:00
|
|
|
this.world.addParticle(Particles.SMOKE, this.locX(), this.locY() + 0.5D, this.locZ(), 0.0D, 0.0D, 0.0D);
|
|
|
|
}
|
2019-05-12 23:42:49 +00:00
|
|
|
}
|
|
|
|
-
|
|
|
|
+ // Paper start - Optional prevent TNT from moving in water
|
|
|
|
+ if (!this.dead && this.inWater && this.world.paperConfig.preventTntFromMovingInWater) {
|
|
|
|
+ /*
|
|
|
|
+ * Author: Jedediah Smith <jedediah@silencegreys.com>
|
|
|
|
+ */
|
2017-05-14 18:05:01 +00:00
|
|
|
+ // 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.
|
2020-06-25 11:00:35 +00:00
|
|
|
+ PlayerChunkMap.EntityTracker ete = ((WorldServer)this.world).getChunkProvider().playerChunkMap.trackedEntities.get(this.getId());
|
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()
|
2019-12-12 18:45:00 +00:00
|
|
|
+ .filter(viewer -> (viewer.locX() - this.locX()) * (viewer.locY() - this.locY()) * (viewer.locZ() - this.locZ()) < 16 * 16)
|
2019-05-12 23:42:49 +00:00
|
|
|
+ .forEach(viewer -> {
|
|
|
|
+ viewer.playerConnection.sendPacket(velocityPacket);
|
|
|
|
+ viewer.playerConnection.sendPacket(positionPacket);
|
|
|
|
+ });
|
2017-05-14 18:05:01 +00:00
|
|
|
+ }
|
|
|
|
+ }
|
2019-05-12 23:42:49 +00:00
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
|
|
|
|
private void explode() {
|
2020-04-08 07:49:15 +00:00
|
|
|
@@ -149,4 +169,11 @@ public class EntityTNTPrimed extends Entity {
|
2020-08-25 02:22:08 +00:00
|
|
|
public Packet<?> P() {
|
2019-05-12 23:42:49 +00:00
|
|
|
return new PacketPlayOutSpawnEntity(this);
|
|
|
|
}
|
2017-05-14 18:05:01 +00:00
|
|
|
+
|
2019-05-12 23:42:49 +00:00
|
|
|
+ // Paper start - Optional prevent TNT from moving in water
|
|
|
|
+ @Override
|
|
|
|
+ public boolean pushedByWater() {
|
|
|
|
+ return !world.paperConfig.preventTntFromMovingInWater && super.pushedByWater();
|
2017-05-14 18:05:01 +00:00
|
|
|
+ }
|
|
|
|
+ // 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
|
2021-02-16 17:08:29 +00:00
|
|
|
index dec48226d713ef0198ef3c679daf553a9d05a099..c346ca8ba30da401ea1a421e8ce6ed1d5b6e4c13 100644
|
2019-05-06 00:57:14 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/EntityTrackerEntry.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/EntityTrackerEntry.java
|
2020-06-25 11:00:35 +00:00
|
|
|
@@ -38,7 +38,7 @@ public class EntityTrackerEntry {
|
2019-05-06 00:57:14 +00:00
|
|
|
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;
|
|
|
|
|