-
Notifications
You must be signed in to change notification settings - Fork 109
/
0028-Make-EntityCollisionContext-a-live-representation.patch
98 lines (89 loc) · 4.39 KB
/
0028-Make-EntityCollisionContext-a-live-representation.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Paul Sauve <paul@technove.co>
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 ebe65474a4a05ff1637d7f37ebcfe690af59def5..42142c512b12e5b269c19f1e821c50e7496a5f25 100644
--- a/src/main/java/net/minecraft/world/phys/shapes/EntityCollisionContext.java
+++ b/src/main/java/net/minecraft/world/phys/shapes/EntityCollisionContext.java
@@ -19,47 +19,66 @@ 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 */
@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) -> {
- return 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) -> {
+ // return 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) - (double)1.0E-5F;
+ return (this.entity == null ? -Double.MAX_VALUE : entity.getY()) > (double)pos.getY() + shape.max(Direction.Axis.Y) - (double)1.0E-5F; // Pufferfish
}
@Nullable