From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Zach Brown 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 index 813994c9f4efc7611cad1633b1a1ea0c99e244d3..b3bc4af0b0be7223318e945c6eee4fe042523934 100644 --- a/src/main/java/net/minecraft/server/level/ServerEntity.java +++ b/src/main/java/net/minecraft/server/level/ServerEntity.java @@ -72,7 +72,7 @@ public class ServerEntity { @Nullable private List> trackedDataValues; // CraftBukkit start - private final Set trackedPlayers; + final Set trackedPlayers; // Paper - private -> package public ServerEntity(ServerLevel worldserver, Entity entity, int i, boolean flag, Consumer> consumer, Set 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 index ab5817df2c98d24ee627fd5cf1f71e40b044e43e..94e3ce40da0401a94a24a6c0f9e7ffa3d0ef850d 100644 --- a/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java +++ b/src/main/java/net/minecraft/world/entity/item/PrimedTnt.java @@ -95,6 +95,27 @@ public class PrimedTnt extends Entity implements TraceableEntity { } } + // Paper start - Optional prevent TNT from moving in water + if (!this.isRemoved() && this.wasTouchingWater && this.level.paperConfig().fixes.preventTntFromMovingInWater) { + /* + * Author: Jedediah Smith + */ + // 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() { @@ -146,4 +167,11 @@ public class PrimedTnt extends Entity implements TraceableEntity { public int getFuse() { return (Integer) this.entityData.get(PrimedTnt.DATA_FUSE_ID); } + + // Paper start - Optional prevent TNT from moving in water + @Override + public boolean isPushedByFluid() { + return !level.paperConfig().fixes.preventTntFromMovingInWater && super.isPushedByFluid(); + } + // Paper end }