From ebb3c9b96a73056ad23a97c5f5e98dbad6ddc0fc Mon Sep 17 00:00:00 2001 From: petersv5 <88165842+petersv5@users.noreply.github.com> Date: Sat, 21 Aug 2021 16:15:29 +0200 Subject: [PATCH] Fix entities glitching through blocks pushed by pistons (#6308) Fixes #5189 --- ...n-to-nerf-pigmen-from-nether-portals.patch | 2 +- .../server/Entity-Activation-Range-2.0.patch | 28 ++++++++++++++++--- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/patches/server/Add-option-to-nerf-pigmen-from-nether-portals.patch b/patches/server/Add-option-to-nerf-pigmen-from-nether-portals.patch index 11e9704dd0..ffab744dcd 100644 --- a/patches/server/Add-option-to-nerf-pigmen-from-nether-portals.patch +++ b/patches/server/Add-option-to-nerf-pigmen-from-nether-portals.patch @@ -25,7 +25,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 --- a/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java @@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n - public long activatedTick = Integer.MIN_VALUE; + public long activatedImmunityTick = Integer.MIN_VALUE; // Paper public boolean isTemporarilyActive = false; // Paper public boolean spawnedViaMobSpawner; // Paper - Yes this name is similar to above, upstream took the better one + public boolean fromNetherPortal; // Paper diff --git a/patches/server/Entity-Activation-Range-2.0.patch b/patches/server/Entity-Activation-Range-2.0.patch index 88e1f8de70..a9ce6e0b3b 100644 --- a/patches/server/Entity-Activation-Range-2.0.patch +++ b/patches/server/Entity-Activation-Range-2.0.patch @@ -131,6 +131,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public final org.spigotmc.ActivationRange.ActivationType activationType = org.spigotmc.ActivationRange.initializeEntityActivationType(this); public final boolean defaultActivationState; public long activatedTick = Integer.MIN_VALUE; ++ public long activatedImmunityTick = Integer.MIN_VALUE; // Paper + public boolean isTemporarilyActive = false; // Paper public boolean spawnedViaMobSpawner; // Paper - Yes this name is similar to above, upstream took the better one protected int numCollisions = 0; // Paper @@ -139,7 +140,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } else { this.wasOnFire = this.isOnFire(); if (movementType == MoverType.PISTON) { -+ this.activatedTick = MinecraftServer.currentTick + 20; // Paper ++ this.activatedTick = Math.max(this.activatedTick, MinecraftServer.currentTick + 20); // Paper ++ this.activatedImmunityTick = Math.max(this.activatedImmunityTick, MinecraftServer.currentTick + 20); // Paper movement = this.limitPistonMovement(movement); if (movement.equals(Vec3.ZERO)) { return; @@ -333,6 +335,21 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public boolean populating; public final org.spigotmc.SpigotWorldConfig spigotConfig; // Spigot +diff --git a/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java b/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java ++++ b/src/main/java/net/minecraft/world/level/block/piston/PistonMovingBlockEntity.java +@@ -0,0 +0,0 @@ public class PistonMovingBlockEntity extends BlockEntity { + } + + entity.setDeltaMovement(e, g, h); ++ // Paper - EAR items stuck in in slime pushed by a piston ++ entity.activatedTick = Math.max(entity.activatedTick, net.minecraft.server.MinecraftServer.currentTick + 10); ++ entity.activatedImmunityTick = Math.max(entity.activatedImmunityTick, net.minecraft.server.MinecraftServer.currentTick + 10); ++ // Paper end + break; + } + } diff --git a/src/main/java/org/spigotmc/ActivationRange.java b/src/main/java/org/spigotmc/ActivationRange.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/spigotmc/ActivationRange.java @@ -525,6 +542,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + if (entity.remainingFireTicks > 0) { + return 2; + } ++ if (entity.activatedImmunityTick >= MinecraftServer.currentTick) { ++ return 1; ++ } + long inactiveFor = MinecraftServer.currentTick - entity.activatedTick; + // Paper end // quick checks. @@ -562,7 +582,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 { - return true; + return 20; // Paper -+ } + } +- if ( entity instanceof Villager && ( (Villager) entity ).canBreed() ) + // Paper start + if (entity instanceof Bee) { + Bee bee = (Bee)entity; @@ -590,8 +611,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + return config.villagersWorkImmunityFor; + } + } - } -- if ( entity instanceof Villager && ( (Villager) entity ).canBreed() ) ++ } + if ( entity instanceof Llama && ( (Llama) entity ).inCaravan() ) { - return true;