2020-05-06 11:48:49 +02:00
|
|
|
From 0000000000000000000000000000000000000000 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
|
2021-01-11 02:44:06 +01:00
|
|
|
index eb04fdb172a50ec1f5b7fe78fa0e7655246abd60..6eca3f300020006f02dd36253b522db442e3cc33 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;
|
|
|
|
|
2021-01-11 02:44:06 +01:00
|
|
|
@@ -291,4 +290,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);
|
|
|
|
+ }
|
|
|
|
}
|
2021-03-16 08:19:45 +01:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/level/EntityTrackerEntry.java b/src/main/java/net/minecraft/server/level/EntityTrackerEntry.java
|
|
|
|
index f5227aa761d326376d057eaadcdbef024ed30241..44b79c97d5cc7570683e1b7f025b4f3ad65beb81 100644
|
|
|
|
--- a/src/main/java/net/minecraft/server/level/EntityTrackerEntry.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/level/EntityTrackerEntry.java
|
|
|
|
@@ -67,7 +67,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;
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
|
|
index 2b1b46bda48c0b137fe914c47a387e6e72a1be40..ee160558d84b24e1309262874a9d433bbe6593f3 100644
|
|
|
|
--- a/src/main/java/net/minecraft/world/entity/Entity.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
|
|
|
|
@@ -2766,6 +2766,11 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, ne
|
2018-07-16 17:34:55 +02:00
|
|
|
}
|
|
|
|
|
2020-11-03 03:22:15 +01:00
|
|
|
public boolean bV() {
|
2019-04-27 08:26:04 +02:00
|
|
|
+ // Paper start
|
2017-05-14 20:05:01 +02:00
|
|
|
+ return this.pushedByWater();
|
|
|
|
+ }
|
|
|
|
+ public boolean pushedByWater() {
|
|
|
|
+ // Paper end
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2021-03-16 08:19:45 +01:00
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/item/EntityTNTPrimed.java b/src/main/java/net/minecraft/world/entity/item/EntityTNTPrimed.java
|
|
|
|
index 535e7d7297d81026b8586d5049b72fa65519b464..ca954912c798a7f4f7c9903a53156075ab688e46 100644
|
|
|
|
--- a/src/main/java/net/minecraft/world/entity/item/EntityTNTPrimed.java
|
|
|
|
+++ b/src/main/java/net/minecraft/world/entity/item/EntityTNTPrimed.java
|
|
|
|
@@ -96,7 +96,27 @@ public class EntityTNTPrimed extends Entity {
|
2019-12-12 00:43:22 +01:00
|
|
|
this.world.addParticle(Particles.SMOKE, this.locX(), this.locY() + 0.5D, this.locZ(), 0.0D, 0.0D, 0.0D);
|
|
|
|
}
|
2019-05-13 01:42:49 +02: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 20:05:01 +02: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 13:00:35 +02:00
|
|
|
+ PlayerChunkMap.EntityTracker ete = ((WorldServer)this.world).getChunkProvider().playerChunkMap.trackedEntities.get(this.getId());
|
2017-05-14 20:05:01 +02:00
|
|
|
+ if (ete != null) {
|
|
|
|
+ PacketPlayOutEntityVelocity velocityPacket = new PacketPlayOutEntityVelocity(this);
|
|
|
|
+ PacketPlayOutEntityTeleport positionPacket = new PacketPlayOutEntityTeleport(this);
|
|
|
|
+
|
2017-05-15 17:28:28 +02:00
|
|
|
+ ete.trackedPlayers.stream()
|
2019-12-12 19:45:00 +01:00
|
|
|
+ .filter(viewer -> (viewer.locX() - this.locX()) * (viewer.locY() - this.locY()) * (viewer.locZ() - this.locZ()) < 16 * 16)
|
2019-05-13 01:42:49 +02:00
|
|
|
+ .forEach(viewer -> {
|
|
|
|
+ viewer.playerConnection.sendPacket(velocityPacket);
|
|
|
|
+ viewer.playerConnection.sendPacket(positionPacket);
|
|
|
|
+ });
|
2017-05-14 20:05:01 +02:00
|
|
|
+ }
|
|
|
|
+ }
|
2019-05-13 01:42:49 +02:00
|
|
|
+ // Paper end
|
|
|
|
}
|
|
|
|
|
|
|
|
private void explode() {
|
2021-03-16 08:19:45 +01:00
|
|
|
@@ -165,4 +185,11 @@ public class EntityTNTPrimed extends Entity {
|
2020-08-25 04:22:08 +02:00
|
|
|
public Packet<?> P() {
|
2019-05-13 01:42:49 +02:00
|
|
|
return new PacketPlayOutSpawnEntity(this);
|
|
|
|
}
|
2017-05-14 20:05:01 +02:00
|
|
|
+
|
2019-05-13 01:42:49 +02:00
|
|
|
+ // Paper start - Optional prevent TNT from moving in water
|
|
|
|
+ @Override
|
|
|
|
+ public boolean pushedByWater() {
|
|
|
|
+ return !world.paperConfig.preventTntFromMovingInWater && super.pushedByWater();
|
2017-05-14 20:05:01 +02:00
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
}
|