Skip to content

Commit

Permalink
Revert "Drop a patch - moonrise includes it"
Browse files Browse the repository at this point in the history
This reverts commit 4d16ae0.
  • Loading branch information
kev626 committed Aug 6, 2024
1 parent 4d16ae0 commit 52c2d05
Show file tree
Hide file tree
Showing 12 changed files with 105 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Paul Sauve <[email protected]>
Date: Sun, 9 May 2021 18:35:05 -0500
Subject: [PATCH] Make EntityCollisionContext a live representation

While Context is in the name, it is not used as a context. Instead it is
always created, use temporarily, then thrown away. This means having a
lot of fields to initialize and make space for is useless. I cannot find
anywhere in the codebase where this is used as a context which may be
saved for later, so this should be safe assuming plugins don't use it
for some strange reason.

diff --git a/src/main/java/net/minecraft/world/phys/shapes/EntityCollisionContext.java b/src/main/java/net/minecraft/world/phys/shapes/EntityCollisionContext.java
index 88a4a72bb390947dc17e5da09a99b2d1b3ac4621..284c76ddb9724b44bb2e93f590685c728e843e6d 100644
--- a/src/main/java/net/minecraft/world/phys/shapes/EntityCollisionContext.java
+++ b/src/main/java/net/minecraft/world/phys/shapes/EntityCollisionContext.java
@@ -17,50 +17,69 @@ public class EntityCollisionContext implements CollisionContext {
return defaultValue;
}
};
- private final boolean descending;
- private final double entityBottom;
- private final ItemStack heldItem;
- private final Predicate<FluidState> canStandOnFluid;
+ // Pufferfish start - remove these and pray no plugin uses them
+ // private final boolean descending;
+ // private final double entityBottom;
+ // private final ItemStack heldItem;
+ // private final Predicate<FluidState> canStandOnFluid;
+ // Pufferfish end
@Nullable
private final Entity entity;

protected EntityCollisionContext(boolean descending, double minY, ItemStack heldItem, Predicate<FluidState> walkOnFluidPredicate, @Nullable Entity entity) {
- this.descending = descending;
- this.entityBottom = minY;
- this.heldItem = heldItem;
- this.canStandOnFluid = walkOnFluidPredicate;
+ // Pufferfish start - remove these
+ // this.descending = descending;
+ // this.entityBottom = minY;
+ // this.heldItem = heldItem;
+ // this.canStandOnFluid = walkOnFluidPredicate;
+ // Pufferfish end
this.entity = entity;
}

@Deprecated
protected EntityCollisionContext(Entity entity) {
- this(
- entity.isDescending(),
- entity.getY(),
- entity instanceof LivingEntity ? ((LivingEntity)entity).getMainHandItem() : ItemStack.EMPTY,
- entity instanceof LivingEntity ? ((LivingEntity)entity)::canStandOnFluid : fluidState -> false,
- entity
- );
+ // Pufferfish start - remove this
+ // this(
+ // entity.isDescending(),
+ // entity.getY(),
+ // entity instanceof LivingEntity ? ((LivingEntity)entity).getMainHandItem() : ItemStack.EMPTY,
+ // entity instanceof LivingEntity ? ((LivingEntity)entity)::canStandOnFluid : fluidState -> false,
+ // entity
+ // );
+ // Pufferfish end
+ this.entity = entity;
}

@Override
public boolean isHoldingItem(Item item) {
- return this.heldItem.is(item);
+ // Pufferfish start
+ Entity entity = this.entity;
+ if (entity instanceof LivingEntity livingEntity) {
+ return livingEntity.getMainHandItem().is(item);
+ }
+ return ItemStack.EMPTY.is(item);
+ // Pufferfish end
}

@Override
public boolean canStandOnFluid(FluidState stateAbove, FluidState state) {
- return this.canStandOnFluid.test(state) && !stateAbove.getType().isSame(state.getType());
+ // Pufferfish start
+ Entity entity = this.entity;
+ if (entity instanceof LivingEntity livingEntity) {
+ return livingEntity.canStandOnFluid(state) && !stateAbove.getType().isSame(state.getType());
+ }
+ return false;
+ // Pufferfish end
}

@Override
public boolean isDescending() {
- return this.descending;
+ return this.entity != null && this.entity.isDescending(); // Pufferfish
}

@Override
public boolean isAbove(VoxelShape shape, BlockPos pos, boolean defaultValue) {
- return this.entityBottom > (double)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) - 1.0E-5F; // Pufferfish
}

@Nullable
File renamed without changes.
File renamed without changes.

0 comments on commit 52c2d05

Please sign in to comment.