Paper/Spigot-Server-Patches/0101-Optional-TNT-doesn-t-move-in-water.patch

108 lines
4.8 KiB
Diff
Raw Normal View History

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
index 05ea87a473228f5b386258fae3943f3f4561eaa6..ac76bdd7e1d91b0d242539c4495948cdfbb622e0 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;
@@ -284,4 +283,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
index c51a80f4cbbbe355e332581559b357dc6abe66bf..3b3b443cd25ef5c327f54c5e784e03bd81c73a7a 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
@@ -2664,6 +2664,11 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
}
2020-06-25 13:00:35 +02:00
public boolean bU() {
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;
}
diff --git a/src/main/java/net/minecraft/server/EntityTNTPrimed.java b/src/main/java/net/minecraft/server/EntityTNTPrimed.java
index 623db6e3befcc7031e68c71f7eb179fce78291c4..3e71332c47000b21ff90aec6937f90dc639a41bd 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
@@ -80,7 +80,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);
}
}
-
+ // 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);
+
+ 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)
+ .forEach(viewer -> {
+ viewer.playerConnection.sendPacket(velocityPacket);
+ viewer.playerConnection.sendPacket(positionPacket);
+ });
2017-05-14 20:05:01 +02:00
+ }
+ }
+ // Paper end
}
private void explode() {
@@ -149,4 +169,11 @@ public class EntityTNTPrimed extends Entity {
public Packet<?> P() {
return new PacketPlayOutSpawnEntity(this);
}
2017-05-14 20:05:01 +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
}
2019-05-06 02:57:14 +02:00
diff --git a/src/main/java/net/minecraft/server/EntityTrackerEntry.java b/src/main/java/net/minecraft/server/EntityTrackerEntry.java
index 50df43653933e3bdeb3fd514a1c6c3b9ac3b15ab..bbb3f88bb15c70aec7f4d223dd3c0cc986c6eb21 100644
2019-05-06 02:57:14 +02:00
--- a/src/main/java/net/minecraft/server/EntityTrackerEntry.java
+++ b/src/main/java/net/minecraft/server/EntityTrackerEntry.java
2020-06-25 13:00:35 +02:00
@@ -38,7 +38,7 @@ public class EntityTrackerEntry {
2019-05-06 02:57:14 +02: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;