9
0
mirror of https://github.com/Dreeam-qwq/Gale.git synced 2025-12-19 14:59:29 +00:00
Files
Gale/patches/server/0021-Make-EntityCollisionContext-a-live-representation.patch
2022-11-25 18:43:23 +01:00

122 lines
5.6 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: MartijnMuijsers <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)
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 <http://www.gnu.org/licenses/>.
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..1bf730336e23eef97d22de7613c63bb9ea0c427c 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,72 @@ public class EntityCollisionContext implements CollisionContext {
return defaultValue;
}
};
+ // 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 ItemStack heldItem;
private final Predicate<FluidState> canStandOnFluid;
+ */
+ // Gale end - Airplane - make EntityCollisionContext a live representation - remove these and pray no plugin uses them
@Nullable
private final Entity entity;
protected EntityCollisionContext(boolean descending, double minY, ItemStack heldItem, Predicate<FluidState> walkOnFluidPredicate, @Nullable Entity entity) {
+ // Gale start - Airplane - make EntityCollisionContext a live representation - remove these and pray no plugin uses them
+ /*
this.descending = descending;
this.entityBottom = minY;
this.heldItem = heldItem;
this.canStandOnFluid = walkOnFluidPredicate;
+ */
+ // Gale end - Airplane - make EntityCollisionContext a live representation - remove these and pray no plugin uses them
this.entity = entity;
}
/** @deprecated */
@Deprecated
protected EntityCollisionContext(Entity entity) {
+ // Gale start - Airplane - make EntityCollisionContext a live representation - remove unneeded things
+ /*
this(entity.isDescending(), entity.getY(), entity instanceof LivingEntity ? ((LivingEntity)entity).getMainHandItem() : ItemStack.EMPTY, entity instanceof LivingEntity ? ((LivingEntity)entity)::canStandOnFluid : (fluidState) -> {
return false;
}, entity);
+ */
+ // Gale end - Airplane - make EntityCollisionContext a live representation - remove unneeded things
+ this.entity = entity;
}
@Override
public boolean isHoldingItem(Item item) {
- return this.heldItem.is(item);
+ // Gale start - Airplane - make EntityCollisionContext a live representation
+ Entity entity = this.entity;
+ if (entity instanceof LivingEntity livingEntity) {
+ return livingEntity.getMainHandItem().is(item);
+ }
+ return ItemStack.EMPTY.is(item);
+ // Gale end - Airplane - make EntityCollisionContext a live representation
}
@Override
public boolean canStandOnFluid(FluidState stateAbove, FluidState state) {
- return this.canStandOnFluid.test(state) && !stateAbove.getType().isSame(state.getType());
+ // Gale start - Airplane - make EntityCollisionContext a live representation
+ Entity entity = this.entity;
+ if (entity instanceof LivingEntity livingEntity) {
+ return livingEntity.canStandOnFluid(state) && !stateAbove.getType().isSame(state.getType());
+ }
+ return false;
+ // Gale end - Airplane - make EntityCollisionContext a live representation
}
@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 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; // Gale - Airplane - make EntityCollisionContext a live representation
}
@Nullable