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

63 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/world/entity/item/PrimedTnt.java b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java
2024-10-22 20:04:31 +02:00
index 3d489fdc14b3e29bab63f330d5edbbc1d354382a..fb631a01e6560632d49d4f59d37ff3bf771da18a 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
2024-10-22 20:04:31 +02:00
@@ -101,7 +101,9 @@ public class PrimedTnt extends Entity implements TraceableEntity {
@Override
public void tick() {
- if (this.level().spigotConfig.maxTntTicksPerTick > 0 && ++this.level().spigotConfig.currentPrimedTnt > this.level().spigotConfig.maxTntTicksPerTick) { return; } // Spigot
+ if (this.level().spigotConfig.maxTntTicksPerTick > 0 && ++this.level().spigotConfig.currentPrimedTnt > this.level().spigotConfig.maxTntTicksPerTick) {
+ return;
+ } // Spigot
this.handlePortal();
this.applyGravity();
this.move(MoverType.SELF, this.getDeltaMovement());
@@ -135,6 +137,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.
2024-10-22 20:04:31 +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() {
2024-10-22 20:04:31 +02:00
@@ -217,8 +240,10 @@ public class PrimedTnt extends Entity implements TraceableEntity {
2024-06-13 19:30:39 +02:00
return entity;
2021-06-12 07:20:08 +02:00
}
2024-10-22 20:04:31 +02:00
+ // Paper start - Option to prevent TNT from moving in water
2024-10-22 20:04:31 +02:00
@Override
- public final boolean hurtServer(ServerLevel world, DamageSource source, float amount) {
- return false;
2021-06-12 07:20:08 +02:00
+ public boolean isPushedByFluid() {
+ return !level().paperConfig().fixes.preventTntFromMovingInWater && super.isPushedByFluid();
2024-10-22 20:04:31 +02:00
}
+ // Paper end - Option to prevent TNT from moving in water
2021-06-12 07:20:08 +02:00
}