9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-19 15:09:25 +00:00
Files
Leaf/leaf-server/minecraft-patches/features/0017-Make-EntityCollisionContext-a-live-representation.patch
2025-06-14 03:34:46 +08:00

124 lines
5.6 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martijn Muijsers <martijnmuijsers@live.nl>
Date: Wed, 23 Nov 2022 22:03:33 +0100
Subject: [PATCH] Make EntityCollisionContext a live representation
License: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
Gale - https://galemc.org
This patch is based on the following patch:
"Make EntityCollisionContext a live representation"
By: Paul Sauve <paul@technove.co>
As part of: Airplane (https://github.com/TECHNOVE/Airplane)
Licensed under: GPL-3.0 (https://www.gnu.org/licenses/gpl-3.0.html)
* Airplane description *
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.
* Airplane copyright *
Airplane
Copyright (C) 2020 Technove LLC
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
diff --git a/net/minecraft/world/phys/shapes/EntityCollisionContext.java b/net/minecraft/world/phys/shapes/EntityCollisionContext.java
index ebc9360ea64a248418fcac8b446664b0dd019335..b09d1b7c76410580663f2419e3b5e917fedabd54 100644
--- a/net/minecraft/world/phys/shapes/EntityCollisionContext.java
+++ b/net/minecraft/world/phys/shapes/EntityCollisionContext.java
@@ -19,27 +19,39 @@ public class EntityCollisionContext implements CollisionContext {
return canAscend;
}
};
+ // Gale start - Airplane - make EntityCollisionContext a live representation - remove these and pray no plugin uses them
+ /*
private final boolean descending;
private final double entityBottom;
private final boolean placement;
private final ItemStack heldItem;
private final Predicate<FluidState> canStandOnFluid;
+ */
+ // Gale end - Airplane - make EntityCollisionContext a live representation - remove these and pray no plugin uses them
+ private final boolean placement;
@Nullable
private final Entity entity;
protected EntityCollisionContext(
boolean descending, boolean placement, double entityBottom, ItemStack heldItem, Predicate<FluidState> canStandOnFluid, @Nullable Entity entity
) {
+ // Gale start - Airplane - make EntityCollisionContext a live representation - remove these and pray no plugin uses them
+ /*
this.descending = descending;
this.placement = placement;
this.entityBottom = entityBottom;
this.heldItem = heldItem;
this.canStandOnFluid = canStandOnFluid;
+ */
+ // Gale end - Airplane - make EntityCollisionContext a live representation - remove these and pray no plugin uses them
+ this.placement = placement;
this.entity = entity;
}
@Deprecated
protected EntityCollisionContext(Entity entity, boolean canStandOnFluid, boolean placement) {
+ // Gale start - Airplane - make EntityCollisionContext a live representation - remove unneeded things
+ /*
this(
entity.isDescending(),
placement,
@@ -50,16 +62,20 @@ public class EntityCollisionContext implements CollisionContext {
: (entity instanceof LivingEntity livingEntity ? fluidState -> livingEntity.canStandOnFluid(fluidState) : fluidState -> false),
entity
);
+ */
+ this.placement = placement;
+ this.entity = entity;
+ // Gale end - Airplane - make EntityCollisionContext a live representation - remove unneeded things
}
@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); // Gale - Airplane - make EntityCollisionContext a live representation
}
@Override
public boolean canStandOnFluid(FluidState fluid1, FluidState fluid2) {
- return this.canStandOnFluid.test(fluid2) && !fluid1.getType().isSame(fluid2.getType());
+ return this.entity instanceof LivingEntity livingEntity && livingEntity.canStandOnFluid(fluid2) && !fluid1.getType().isSame(fluid2.getType()); // Gale - Airplane - make EntityCollisionContext a live representation
}
@Override
@@ -69,12 +85,12 @@ public class EntityCollisionContext implements CollisionContext {
@Override
public boolean isDescending() {
- return this.descending;
+ return this.entity != null && this.entity.isDescending(); // Gale - Airplane - 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; // Gale - Airplane - make EntityCollisionContext a live representation
}
@Nullable