9
0
mirror of https://github.com/Winds-Studio/Leaf.git synced 2025-12-26 02:19:19 +00:00
Files
Leaf/patches/server/0037-Reduce-canSee-work.patch
2024-05-25 17:06:00 +08:00

64 lines
3.4 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com>
Date: Mon, 11 Sep 2023 15:47:19 -0400
Subject: [PATCH] Reduce canSee work
Credit by: Martijn Muijsers <martijnmuijsers@live.nl>, MachineBreaker<machinebreaker>
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index 78f2bea7ae34be7a2152d7c31e90a524eac1ddfe..9ce1676e9a51ae7fd59bc4ef29efdcb160a86657 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -442,11 +442,7 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
for (int i = 0, len = entities.size(); i < len; ++i) {
Entity entity = entities.get(i);
- if (checkCanSee && source instanceof net.minecraft.server.level.ServerPlayer && entity instanceof net.minecraft.server.level.ServerPlayer
- && !((net.minecraft.server.level.ServerPlayer) source).getBukkitEntity().canSee(((net.minecraft.server.level.ServerPlayer) entity).getBukkitEntity())) {
- continue;
- }
-
+ // Leaf - move up
// !entity1.dead && entity1.i && (entity == null || !entity1.x(entity));
// elide the last check since vanilla calls with entity = null
// only we care about the source for the canSee check
@@ -454,6 +450,11 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
continue;
}
+ if (checkCanSee && source instanceof net.minecraft.server.level.ServerPlayer && entity instanceof net.minecraft.server.level.ServerPlayer
+ && !((net.minecraft.server.level.ServerPlayer) source).getBukkitEntity().canSee(((net.minecraft.server.level.ServerPlayer) entity).getBukkitEntity())) {
+ continue;
+ }
+
if (net.minecraft.world.phys.shapes.Shapes.joinIsNotEmpty(voxelshape, net.minecraft.world.phys.shapes.Shapes.create(entity.getBoundingBox()), net.minecraft.world.phys.shapes.BooleanOp.AND)) {
return false;
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 41d67b3c57f55c6b5f685d8b00ca98ae1cd82881..b988261eebba51f4205df8ffe8661e7539c72c9c 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -578,12 +578,14 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
this.getHandle().connection.send(packet);
}
+ // Leaf - TODO
@Override
public boolean equals(Object obj) {
if (!(obj instanceof OfflinePlayer)) {
return false;
}
OfflinePlayer other = (OfflinePlayer) obj;
+ if (this == obj) return true; // Leaf
if ((this.getUniqueId() == null) || (other.getUniqueId() == null)) {
return false;
}
@@ -2100,6 +2102,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
return this.canSee((org.bukkit.entity.Entity) player);
}
+ // Leaf - TODO
@Override
public boolean canSee(org.bukkit.entity.Entity entity) {
return this.equals(entity) || entity.isVisibleByDefault() ^ this.invertedVisibilityEntities.containsKey(entity.getUniqueId()); // SPIGOT-7312: Can always see self