From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: NONPLAYT <76615486+NONPLAYT@users.noreply.github.com> Date: Tue, 14 Oct 2025 01:42:43 +0300 Subject: [PATCH] Pufferfish: Make EntityCollisionContext a live representation This patch is based on the following patch: "Make EntityCollisionContext a live representation" By: Paul Sauve As part of: Airplane (https://github.com/TECHNOVE/Airplane) Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html) diff --git a/net/minecraft/world/phys/shapes/EntityCollisionContext.java b/net/minecraft/world/phys/shapes/EntityCollisionContext.java index a2d7eb19fc8963f80c94761138b7c43af0e44fe9..c9b1f73cffd2bcfb426324dcbe15fd599fac0bbf 100644 --- a/net/minecraft/world/phys/shapes/EntityCollisionContext.java +++ b/net/minecraft/world/phys/shapes/EntityCollisionContext.java @@ -12,40 +12,35 @@ import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.material.FluidState; public class EntityCollisionContext implements CollisionContext { - private final boolean descending; - private final double entityBottom; + // DivineMC start - Pufferfish: Make EntityCollisionContext a live representation private final boolean placement; - private final ItemStack heldItem; private final boolean alwaysCollideWithFluid; + // DivineMC end - Pufferfish: Make EntityCollisionContext a live representation @Nullable private final Entity entity; protected EntityCollisionContext( boolean descending, boolean placement, double entityBottom, ItemStack heldItem, boolean alwaysCollideWithFluid, @Nullable Entity entity ) { - this.descending = descending; + // DivineMC start - Pufferfish: Make EntityCollisionContext a live representation this.placement = placement; - this.entityBottom = entityBottom; - this.heldItem = heldItem; this.alwaysCollideWithFluid = alwaysCollideWithFluid; + // DivineMC end - Pufferfish: Make EntityCollisionContext a live representation this.entity = entity; } @Deprecated protected EntityCollisionContext(Entity entity, boolean alwaysCollideWithFluid, boolean placement) { - this( - entity.isDescending(), - placement, - entity.getY(), - entity instanceof LivingEntity livingEntity ? livingEntity.getMainHandItem() : ItemStack.EMPTY, - alwaysCollideWithFluid, - entity - ); + // DivineMC start - Pufferfish: Make EntityCollisionContext a live representation + this.placement = placement; + this.alwaysCollideWithFluid = alwaysCollideWithFluid; + this.entity = entity; + // DivineMC end - Pufferfish: Make EntityCollisionContext a live representation } @Override public boolean isHoldingItem(Item item) { - return this.heldItem.is(item); + return this.entity instanceof LivingEntity livingEntity ? livingEntity.getMainHandItem().is(item) : ItemStack.EMPTY.is(item); // DivineMC - Pufferfish: Make EntityCollisionContext a live representation } @Override @@ -65,12 +60,12 @@ public class EntityCollisionContext implements CollisionContext { @Override public boolean isDescending() { - return this.descending; + return this.entity != null && this.entity.isDescending(); // DivineMC - Pufferfish: Make EntityCollisionContext a live representation } @Override public boolean isAbove(VoxelShape shape, BlockPos pos, boolean canAscend) { - return this.entityBottom > pos.getY() + shape.max(Direction.Axis.Y) - 1.0E-5F; + return (this.entity == null ? -Double.MAX_VALUE : entity.getY()) > (double) pos.getY() + shape.max(Direction.Axis.Y) - (double) 1.0E-5F; // DivineMC - Pufferfish: Make EntityCollisionContext a live representation } @Nullable