2021-06-12 07:20:08 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
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/net/minecraft/server/level/ServerEntity.java b/src/main/java/net/minecraft/server/level/ServerEntity.java
2023-07-04 10:22:56 +02:00
index 7bcf878cbb10f4d99e9693532d02b87350da3b06..71219297a175ff9549a258985043df3ce7545ae6 100644
2021-06-12 07:20:08 +02:00
--- a/src/main/java/net/minecraft/server/level/ServerEntity.java
+++ b/src/main/java/net/minecraft/server/level/ServerEntity.java
2023-06-07 21:19:26 +02:00
@@ -70,7 +70,7 @@ public class ServerEntity {
2022-12-07 19:52:24 +01:00
@Nullable
private List<SynchedEntityData.DataValue<?>> trackedDataValues;
2021-06-12 07:20:08 +02:00
// CraftBukkit start
- private final Set<ServerPlayerConnection> trackedPlayers;
+ final Set<ServerPlayerConnection> trackedPlayers; // Paper - private -> package
public ServerEntity(ServerLevel worldserver, Entity entity, int i, boolean flag, Consumer<Packet<?>> consumer, Set<ServerPlayerConnection> trackedPlayers) {
this.trackedPlayers = trackedPlayers;
diff --git a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
2023-07-04 10:22:56 +02:00
index 89fd5d6b373d2705dccc2f22663048f4c2aaa60f..57f9bf73ee14bc8811d0192543caf2b02e890ee0 100644
2021-06-12 07:20:08 +02:00
--- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
+++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
2023-07-04 10:22:56 +02:00
@@ -98,6 +98,27 @@ public class PrimedTnt extends Entity implements TraceableEntity {
2021-06-12 07:20:08 +02:00
}
}
+ // Paper start - Optional prevent TNT from moving in water
2023-06-08 00:28:06 +02:00
+ if (!this.isRemoved() && this.wasTouchingWater && this.level().paperConfig().fixes.preventTntFromMovingInWater) {
2021-06-12 07:20:08 +02:00
+ /*
+ * Author: Jedediah Smith <jedediah@silencegreys.com>
+ */
+ // 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.
2023-06-08 00:28:06 +02:00
+ net.minecraft.server.level.ChunkMap.TrackedEntity ete = ((net.minecraft.server.level.ServerLevel)this.level()).getChunkSource().chunkMap.entityMap.get(this.getId());
2021-06-12 07:20:08 +02:00
+ if (ete != null) {
+ net.minecraft.network.protocol.game.ClientboundSetEntityMotionPacket velocityPacket = new net.minecraft.network.protocol.game.ClientboundSetEntityMotionPacket(this);
+ net.minecraft.network.protocol.game.ClientboundTeleportEntityPacket positionPacket = new net.minecraft.network.protocol.game.ClientboundTeleportEntityPacket(this);
+
+ ete.seenBy.stream()
+ .filter(viewer -> (viewer.getPlayer().getX() - this.getX()) * (viewer.getPlayer().getY() - this.getY()) * (viewer.getPlayer().getZ() - this.getZ()) < 16 * 16)
+ .forEach(viewer -> {
+ viewer.send(velocityPacket);
+ viewer.send(positionPacket);
+ });
+ }
+ }
+ // Paper end
}
private void explode() {
2023-07-04 10:22:56 +02:00
@@ -147,4 +168,11 @@ public class PrimedTnt extends Entity implements TraceableEntity {
2022-12-07 19:52:24 +01:00
public int getFuse() {
return (Integer) this.entityData.get(PrimedTnt.DATA_FUSE_ID);
2021-06-12 07:20:08 +02:00
}
+
+ // Paper start - Optional prevent TNT from moving in water
+ @Override
+ public boolean isPushedByFluid() {
2023-06-08 01:21:20 +02:00
+ return !level().paperConfig().fixes.preventTntFromMovingInWater && super.isPushedByFluid();
2021-06-12 07:20:08 +02:00
+ }
+ // Paper end
}