Paper/patches/server/0098-Optional-TNT-doesn-t-move-in-water.patch

64 lines
3.4 KiB
Diff
Raw Normal View History

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
2022-12-07 19:52:24 +01:00
index 6b372ac843e992820ac0a8ebb9c3c5d9795cc6b0..841bb7741ae6b0e9cb98120ee1649b93ef4c3dab 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
2022-12-07 19:52:24 +01:00
@@ -69,7 +69,7 @@ public class ServerEntity {
@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
2022-12-07 19:52:24 +01:00
index aa0dfd08aefbb9363ec96080432f0f75d71b0b95..4b81d62d3250b99cbcb4eb2468ef81c149bf177e 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
2022-12-07 19:52:24 +01:00
@@ -94,6 +94,27 @@ public class PrimedTnt extends Entity {
2021-06-12 07:20:08 +02:00
}
}
+ // Paper start - Optional prevent TNT from moving in water
+ 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.
+ net.minecraft.server.level.ChunkMap.TrackedEntity ete = ((net.minecraft.server.level.ServerLevel)this.level).getChunkSource().chunkMap.entityMap.get(this.getId());
+ 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() {
2022-12-07 19:52:24 +01:00
@@ -144,4 +165,11 @@ public class PrimedTnt extends Entity {
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() {
+ return !level.paperConfig().fixes.preventTntFromMovingInWater && super.isPushedByFluid();
2021-06-12 07:20:08 +02:00
+ }
+ // Paper end
}