3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-15 12:30:06 +01:00
Paper/patches/server/0096-Optional-TNT-doesn-t-move-in-water.patch

51 Zeilen
2.7 KiB
Diff

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/world/entity/item/PrimedTnt.java b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
index 19e2f2005bd1fb4d199debd34e92a0794a3d3fe4..3408337b11f04337bb2f62de343e430d94d3a093 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-12-05 22:20:44 +01:00
@@ -106,6 +106,27 @@ public class PrimedTnt extends Entity implements TraceableEntity {
2021-06-12 07:20:08 +02:00
}
}
+ // Paper start - Option to 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 - Option to prevent TNT from moving in water
2021-06-12 07:20:08 +02:00
}
private void explode() {
@@ -171,4 +192,11 @@ public class PrimedTnt extends Entity implements TraceableEntity {
2023-12-05 22:20:44 +01:00
public BlockState getBlockState() {
return (BlockState) this.entityData.get(PrimedTnt.DATA_BLOCK_STATE_ID);
2021-06-12 07:20:08 +02:00
}
+
+ // Paper start - Option to prevent TNT from moving in water
2021-06-12 07:20:08 +02:00
+ @Override
+ public boolean isPushedByFluid() {
+ return !level().paperConfig().fixes.preventTntFromMovingInWater && super.isPushedByFluid();
2021-06-12 07:20:08 +02:00
+ }
+ // Paper end - Option to prevent TNT from moving in water
2021-06-12 07:20:08 +02:00
}