diff options
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/entity/EntitySelector.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower/net/minecraft/world/entity/EntitySelector.java.patch | 143 |
1 files changed, 143 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/entity/EntitySelector.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/entity/EntitySelector.java.patch new file mode 100644 index 0000000000..8de0056976 --- /dev/null +++ b/patch-remap/mache-vineflower/net/minecraft/world/entity/EntitySelector.java.patch @@ -0,0 +1,143 @@ +--- a/net/minecraft/world/entity/EntitySelector.java ++++ b/net/minecraft/world/entity/EntitySelector.java +@@ -6,75 +6,98 @@ + import net.minecraft.world.Container; + import net.minecraft.world.entity.player.Player; + import net.minecraft.world.item.ItemStack; ++import net.minecraft.world.scores.PlayerTeam; + import net.minecraft.world.scores.Team; + + public final class EntitySelector { ++ + public static final Predicate<Entity> ENTITY_STILL_ALIVE = Entity::isAlive; +- public static final Predicate<Entity> LIVING_ENTITY_STILL_ALIVE = entity -> entity.isAlive() && entity instanceof LivingEntity; +- public static final Predicate<Entity> ENTITY_NOT_BEING_RIDDEN = entity -> entity.isAlive() && !entity.isVehicle() && !entity.isPassenger(); +- public static final Predicate<Entity> CONTAINER_ENTITY_SELECTOR = entity -> entity instanceof Container && entity.isAlive(); +- public static final Predicate<Entity> NO_CREATIVE_OR_SPECTATOR = entity -> !(entity instanceof Player) +- || !entity.isSpectator() && !((Player)entity).isCreative(); +- public static final Predicate<Entity> NO_SPECTATORS = entity -> !entity.isSpectator(); +- public static final Predicate<Entity> CAN_BE_COLLIDED_WITH = NO_SPECTATORS.and(Entity::canBeCollidedWith); ++ public static final Predicate<Entity> LIVING_ENTITY_STILL_ALIVE = (entity) -> { ++ return entity.isAlive() && entity instanceof LivingEntity; ++ }; ++ public static final Predicate<Entity> ENTITY_NOT_BEING_RIDDEN = (entity) -> { ++ return entity.isAlive() && !entity.isVehicle() && !entity.isPassenger(); ++ }; ++ public static final Predicate<Entity> CONTAINER_ENTITY_SELECTOR = (entity) -> { ++ return entity instanceof Container && entity.isAlive(); ++ }; ++ public static final Predicate<Entity> NO_CREATIVE_OR_SPECTATOR = (entity) -> { ++ return !(entity instanceof Player) || !entity.isSpectator() && !((Player) entity).isCreative(); ++ }; ++ public static final Predicate<Entity> NO_SPECTATORS = (entity) -> { ++ return !entity.isSpectator(); ++ }; ++ public static final Predicate<Entity> CAN_BE_COLLIDED_WITH = EntitySelector.NO_SPECTATORS.and(Entity::canBeCollidedWith); + +- private EntitySelector() { +- } ++ private EntitySelector() {} + +- public static Predicate<Entity> withinDistance(double x, double y, double z, double range) { +- double d = range * range; +- return entity -> entity != null && entity.distanceToSqr(x, y, z) <= d; ++ public static Predicate<Entity> withinDistance(double x, double d1, double y, double d3) { ++ double d4 = d3 * d3; ++ ++ return (entity) -> { ++ return entity != null && entity.distanceToSqr(x, d1, y) <= d4; ++ }; + } + + public static Predicate<Entity> pushableBy(Entity entity) { +- Team team = entity.getTeam(); +- Team.CollisionRule collisionRule = team == null ? Team.CollisionRule.ALWAYS : team.getCollisionRule(); +- return (Predicate<Entity>)(collisionRule == Team.CollisionRule.NEVER +- ? Predicates.alwaysFalse() +- : NO_SPECTATORS.and( +- pushedEntity -> { +- if (!pushedEntity.isPushable()) { +- return false; +- } else if (!entity.level().isClientSide || pushedEntity instanceof Player && ((Player)pushedEntity).isLocalPlayer()) { +- Team team1 = pushedEntity.getTeam(); +- Team.CollisionRule collisionRule1 = team1 == null ? Team.CollisionRule.ALWAYS : team1.getCollisionRule(); +- if (collisionRule1 == Team.CollisionRule.NEVER) { +- return false; +- } else { +- boolean flag = team != null && team.isAlliedTo(team1); +- return (collisionRule != Team.CollisionRule.PUSH_OWN_TEAM && collisionRule1 != Team.CollisionRule.PUSH_OWN_TEAM || !flag) +- && (collisionRule != Team.CollisionRule.PUSH_OTHER_TEAMS && collisionRule1 != Team.CollisionRule.PUSH_OTHER_TEAMS || flag); +- } +- } else { +- return false; +- } ++ PlayerTeam scoreboardteam = entity.getTeam(); ++ Team.CollisionRule scoreboardteambase_enumteampush = scoreboardteam == null ? Team.CollisionRule.ALWAYS : scoreboardteam.getCollisionRule(); ++ ++ return (Predicate) (scoreboardteambase_enumteampush == Team.CollisionRule.NEVER ? Predicates.alwaysFalse() : EntitySelector.NO_SPECTATORS.and((entity1) -> { ++ if (!entity1.canCollideWithBukkit(entity) || !entity.canCollideWithBukkit(entity1)) { // CraftBukkit - collidable API ++ return false; ++ } else if (entity.level().isClientSide && (!(entity1 instanceof Player) || !((Player) entity1).isLocalPlayer())) { ++ return false; ++ } else { ++ PlayerTeam scoreboardteam1 = entity1.getTeam(); ++ Team.CollisionRule scoreboardteambase_enumteampush1 = scoreboardteam1 == null ? Team.CollisionRule.ALWAYS : scoreboardteam1.getCollisionRule(); ++ ++ if (scoreboardteambase_enumteampush1 == Team.CollisionRule.NEVER) { ++ return false; ++ } else { ++ boolean flag = scoreboardteam != null && scoreboardteam.isAlliedTo(scoreboardteam1); ++ ++ return (scoreboardteambase_enumteampush == Team.CollisionRule.PUSH_OWN_TEAM || scoreboardteambase_enumteampush1 == Team.CollisionRule.PUSH_OWN_TEAM) && flag ? false : scoreboardteambase_enumteampush != Team.CollisionRule.PUSH_OTHER_TEAMS && scoreboardteambase_enumteampush1 != Team.CollisionRule.PUSH_OTHER_TEAMS || flag; + } +- )); ++ } ++ })); + } + + public static Predicate<Entity> notRiding(Entity entity) { +- return passenger -> { +- while (passenger.isPassenger()) { +- passenger = passenger.getVehicle(); +- if (passenger == entity) { ++ return (entity1) -> { ++ while (true) { ++ if (entity1.isPassenger()) { ++ entity1 = entity1.getVehicle(); ++ if (entity1 != entity) { ++ continue; ++ } ++ + return false; + } +- } + +- return true; ++ return true; ++ } + }; + } + + public static class MobCanWearArmorEntitySelector implements Predicate<Entity> { ++ + private final ItemStack itemStack; + + public MobCanWearArmorEntitySelector(ItemStack stack) { + this.itemStack = stack; + } + +- @Override + public boolean test(@Nullable Entity entity) { +- return entity.isAlive() && entity instanceof LivingEntity livingEntity && livingEntity.canTakeItem(this.itemStack); ++ if (!entity.isAlive()) { ++ return false; ++ } else if (!(entity instanceof LivingEntity)) { ++ return false; ++ } else { ++ LivingEntity entityliving = (LivingEntity) entity; ++ ++ return entityliving.canTakeItem(this.itemStack); ++ } + } + } + } |