mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-20 09:57:43 +01:00
Upstream has released updates that appear to apply and compile correctly Paper Changes: 7232d8f2a EntityLoadCrossbowEvent#shouldConsumeItem 4740bd6c8 Mark PlayerInventory#getItem as nullable bd9ace578 Add a config option to limit the number of entities of each type to load/save in a chunk (#4792) 6bafeb5a9 Move logic from last patch into correct place 9668118fd disable entity ticking flag after watchdog obliteration
77 lines
3.2 KiB
Diff
77 lines
3.2 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: James Lyne <jim+github@not-null.co.uk>
|
|
Date: Mon, 7 Dec 2020 17:52:36 +0000
|
|
Subject: [PATCH] Spread out and optimise player list ticks
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/PlayerList.java b/src/main/java/net/minecraft/server/PlayerList.java
|
|
index 156c55666f6a9ba7108499f513d251aacbcd9fe8..2f1a2fa1f80ed23c67db1d01023a04b5074d1654 100644
|
|
--- a/src/main/java/net/minecraft/server/PlayerList.java
|
|
+++ b/src/main/java/net/minecraft/server/PlayerList.java
|
|
@@ -71,7 +71,7 @@ public abstract class PlayerList {
|
|
private int viewDistance;
|
|
private EnumGamemode u;
|
|
private boolean v;
|
|
- private int w;
|
|
+ private int w; private int getTick() { return this.w; } private int setTick(int i) { return this.w = i; } // Purpur - OBFHELPER
|
|
|
|
// CraftBukkit start
|
|
private CraftServer cserver;
|
|
@@ -928,22 +928,23 @@ public abstract class PlayerList {
|
|
}
|
|
|
|
public void tick() {
|
|
- if (++this.w > 600) {
|
|
- // CraftBukkit start
|
|
- for (int i = 0; i < this.players.size(); ++i) {
|
|
- final EntityPlayer target = (EntityPlayer) this.players.get(i);
|
|
-
|
|
- target.playerConnection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_LATENCY, Iterables.filter(this.players, new Predicate<EntityPlayer>() {
|
|
- @Override
|
|
- public boolean apply(EntityPlayer input) {
|
|
- return target.getBukkitEntity().canSee(input.getBukkitEntity());
|
|
- }
|
|
- })));
|
|
+ // Purpur start
|
|
+ int tick = getTick();
|
|
+ if (tick < this.players.size()) {
|
|
+ final org.bukkit.craftbukkit.entity.CraftPlayer target = this.players.get(tick).getBukkitEntity();
|
|
+ final java.util.List<EntityPlayer> list = new java.util.ArrayList<>();
|
|
+ for (EntityPlayer entityplayer : this.players) {
|
|
+ if (target.canSee(entityplayer.getUniqueID())) {
|
|
+ list.add(entityplayer);
|
|
+ }
|
|
}
|
|
- // CraftBukkit end
|
|
- this.w = 0;
|
|
+ target.getHandle().playerConnection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.UPDATE_LATENCY, list));
|
|
}
|
|
-
|
|
+ if (++tick > 600) {
|
|
+ tick = 0;
|
|
+ }
|
|
+ setTick(tick);
|
|
+ // Purpur end
|
|
}
|
|
|
|
public void sendAll(Packet<?> packet) {
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
index e781ae267d4c546261a1dcdfc24d9924eb5044fd..4f42bc21839086b2a40a35910a08d9b11c7649f9 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
@@ -1382,7 +1382,13 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|
|
|
@Override
|
|
public boolean canSee(Player player) {
|
|
- return !hiddenPlayers.containsKey(player.getUniqueId());
|
|
+ // Purpur start
|
|
+ return canSee(player.getUniqueId());
|
|
+ }
|
|
+
|
|
+ public boolean canSee(UUID uuid) {
|
|
+ return !hiddenPlayers.containsKey(uuid);
|
|
+ // Purpur end
|
|
}
|
|
|
|
@Override
|