Avoid players seeing item frames to optimise maps in item frames

This commit is contained in:
fullwall 2022-01-02 01:54:27 +08:00
parent bf3bf6f776
commit fe15df7c8b

View File

@ -11,6 +11,7 @@ import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_18_R1.CraftServer; import org.bukkit.craftbukkit.v1_18_R1.CraftServer;
import org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.metadata.MetadataValue; import org.bukkit.metadata.MetadataValue;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
@ -548,6 +549,14 @@ public class EntityHumanNPC extends ServerPlayer implements NPCHolder, Skinnable
npc.getOrAddTrait(Inventory.class); npc.getOrAddTrait(Inventory.class);
} }
@Override
public boolean canSee(org.bukkit.entity.Entity entity) {
if (entity.getType() == EntityType.ITEM_FRAME) {
return false; // optimise for large maps in item frames
}
return super.canSee(entity);
}
@Override @Override
public Player getBukkitEntity() { public Player getBukkitEntity() {
return this; return this;