3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-15 04:20:04 +01:00
Paper/CraftBukkit-Patches/0022-Only-send-maps-in-item-frames-upon-tracking.patch
Aikar e9950b70d3 Overhaul to Timings and Entity Activation Range
This greatly extends the timings improvements I've done in recent commits, and brings timings to fully cover the entire tick.
The timings system also now tracks when specific timings causes the server to lose TPS.
The timings are also able to be turned on "on demand", meaning you do not need to restart the server to enable them.

This commit also overhauls the Entity Activation Range feature, fixing bugs, adding more immunities, and improving the performance of it.
It also fixes a regression with a recent Spigot commit that broke the entire Entity Activation Range feature.

This commit had to move the Tick Loop patch before timings because there was a change done there to time the entire tick, so lots of renames.

These 2 commits had to be bundled together to simplify applying them and reduce redundant conflict resolution.
2013-02-27 07:29:33 +11:00

90 Zeilen
4.2 KiB
Diff

From 14f2f48d062b71bdd20a50cb8bbd3a7a8a0d3621 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Tue, 19 Feb 2013 17:26:20 -0500
Subject: [PATCH] Only send maps in item frames upon tracking
Maps in item frames are full of bugs.
1) It sends an update of the Maps data to ALL players in the world, not just the players tracking it.
2) It sends an update EVERY tick, not every 10 ticks as intended.
To optimize performance of maps in item frames, we will only send it once a player tracks the ItemFrame until it completes, then that player will not receive more updates.
This means cursors will not dynamically update, but the map data should refresh every time the player moves away then back.
---
.../net/minecraft/server/EntityTrackerEntry.java | 25 ++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)
diff --git a/src/main/java/net/minecraft/server/EntityTrackerEntry.java b/src/main/java/net/minecraft/server/EntityTrackerEntry.java
index a026c4c..75c146d 100644
--- a/src/main/java/net/minecraft/server/EntityTrackerEntry.java
+++ b/src/main/java/net/minecraft/server/EntityTrackerEntry.java
@@ -36,6 +36,7 @@ public class EntityTrackerEntry {
public boolean n = false;
public Set trackedPlayers = new HashSet();
+ public List<EntityPlayer> playersToUpdate = new java.util.ArrayList<EntityPlayer>(); // Spigot
public EntityTrackerEntry(Entity entity, int i, int j, boolean flag) {
this.tracker = entity;
this.b = i;
@@ -73,17 +74,17 @@ public class EntityTrackerEntry {
this.broadcast(new Packet39AttachEntity(this.tracker, this.tracker.vehicle));
}
- if (this.tracker instanceof EntityItemFrame && this.m % 10 == 0) {
+ if (this.tracker instanceof EntityItemFrame) { // Spigot - has to be ran every tick for general frames or they may pop off?
EntityItemFrame i4 = (EntityItemFrame) this.tracker;
ItemStack i5 = i4.i();
- if (i5 != null && i5.getItem() instanceof ItemWorldMap) {
+ if (this.m++ % 10 == 0 && i5 != null && i5.getItem() instanceof ItemWorldMap && playersToUpdate.size() > 0) { // Spigot
WorldMap i7 = Item.MAP.getSavedMap(i5, this.tracker.world);
- Iterator j0 = list.iterator();
+ Iterator j0 = playersToUpdate.iterator(); // Spigot
while (j0.hasNext()) {
- EntityHuman j1 = (EntityHuman) j0.next();
- EntityPlayer j2 = (EntityPlayer) j1;
+ //EntityHuman j1 = (EntityHuman) j0.next(); // Spigot - unused
+ EntityPlayer j2 = (EntityPlayer) j0.next(); // Spigot
i7.a(j2, i5);
if (j2.playerConnection.lowPriorityCount() <= 5) {
@@ -91,7 +92,7 @@ public class EntityTrackerEntry {
if (j3 != null) {
j2.playerConnection.sendPacket(j3);
- }
+ } else { j0.remove(); } // Spigot
}
}
}
@@ -329,6 +330,17 @@ public class EntityTrackerEntry {
}
}
+ // Spigot start - add player to list to receive initial map updates.
+ if (this.tracker instanceof EntityItemFrame) {
+ EntityItemFrame i4 = (EntityItemFrame) this.tracker;
+ ItemStack i5 = i4.i();
+
+ if (i5 != null && i5.getItem() instanceof ItemWorldMap) {
+ this.playersToUpdate.add(entityplayer);
+ }
+ }
+ // Spigot end
+
if (this.tracker instanceof EntityHuman) {
EntityHuman entityhuman = (EntityHuman) this.tracker;
@@ -355,6 +367,7 @@ public class EntityTrackerEntry {
}
} else if (this.trackedPlayers.contains(entityplayer)) {
this.trackedPlayers.remove(entityplayer);
+ this.playersToUpdate.remove(entityplayer); // Spigot
entityplayer.removeQueue.add(Integer.valueOf(this.tracker.id));
}
}
--
1.8.1.1