2018-07-16 23:34:55 +08:00
|
|
|
From 2cfae6d7882500d8af89756f8353d22d148098f1 Mon Sep 17 00:00:00 2001
|
2016-04-30 08:04:12 +08:00
|
|
|
From: Aikar <aikar@aikar.co>
|
|
|
|
Date: Fri, 29 Apr 2016 20:02:00 -0400
|
|
|
|
Subject: [PATCH] Improve Maps (in item frames) performance and bug fixes
|
|
|
|
|
|
|
|
Maps used a modified version of rendering to support plugin controlled
|
|
|
|
imaging on maps. The Craft Map Renderer is much slower than Vanilla,
|
|
|
|
causing maps in item frames to cause a noticeable hit on server performance.
|
|
|
|
|
|
|
|
This updates the map system to not use the Craft system if we detect that no
|
|
|
|
custom renderers are in use, defaulting to the much simpler Vanilla system.
|
|
|
|
|
|
|
|
Additionally, numerous issues to player position tracking on maps has been fixed.
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java
|
2018-07-16 23:34:55 +08:00
|
|
|
index 1aa32bf11..36a961cb7 100644
|
2016-04-30 08:04:12 +08:00
|
|
|
--- a/src/main/java/net/minecraft/server/EntityHuman.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
|
2018-07-16 23:34:55 +08:00
|
|
|
@@ -610,6 +610,12 @@ public abstract class EntityHuman extends EntityLiving {
|
2016-04-30 08:04:12 +08:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
|
|
|
+ // Paper start - remove player from map on drop
|
|
|
|
+ if (itemstack.getItem() == Items.FILLED_MAP) {
|
|
|
|
+ WorldMap worldmap = Items.FILLED_MAP.getSavedMap(itemstack, this.world);
|
|
|
|
+ worldmap.updateSeenPlayers(this, itemstack);
|
|
|
|
+ }
|
|
|
|
+ // Paper stop
|
|
|
|
|
|
|
|
ItemStack itemstack1 = this.a(entityitem);
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/EntityTrackerEntry.java b/src/main/java/net/minecraft/server/EntityTrackerEntry.java
|
2018-07-16 23:34:55 +08:00
|
|
|
index 6ae576a2e..af1981967 100644
|
2016-04-30 08:04:12 +08:00
|
|
|
--- a/src/main/java/net/minecraft/server/EntityTrackerEntry.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/EntityTrackerEntry.java
|
2018-07-16 23:34:55 +08:00
|
|
|
@@ -90,7 +90,7 @@ public class EntityTrackerEntry {
|
2016-04-30 08:04:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// PAIL : rename
|
|
|
|
- if (this.tracker instanceof EntityItemFrame /*&& this.a % 10 == 0*/) { // CraftBukkit - Moved below, should always enter this block
|
|
|
|
+ if (this.tracker instanceof EntityItemFrame && this.a % 20 == 0) { // Paper
|
|
|
|
EntityItemFrame entityitemframe = (EntityItemFrame) this.tracker;
|
|
|
|
ItemStack itemstack = entityitemframe.getItem();
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
2018-07-16 23:34:55 +08:00
|
|
|
index 3b3cc69de..4588df4b1 100644
|
2016-04-30 08:04:12 +08:00
|
|
|
--- a/src/main/java/net/minecraft/server/World.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/World.java
|
2018-07-16 23:34:55 +08:00
|
|
|
@@ -1075,6 +1075,7 @@ public abstract class World implements GeneratorAccess, IIBlockAccess, AutoClose
|
2016-04-30 08:04:12 +08:00
|
|
|
{
|
|
|
|
if ( iter.next().trackee == entity )
|
|
|
|
{
|
|
|
|
+ map.decorations.remove(entity.getUniqueID()); // Paper
|
|
|
|
iter.remove();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/WorldMap.java b/src/main/java/net/minecraft/server/WorldMap.java
|
2018-07-16 23:34:55 +08:00
|
|
|
index 445a016b7..4c64f90be 100644
|
2016-04-30 08:04:12 +08:00
|
|
|
--- a/src/main/java/net/minecraft/server/WorldMap.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/WorldMap.java
|
2018-07-16 23:34:55 +08:00
|
|
|
@@ -29,6 +29,7 @@ public class WorldMap extends PersistentBase {
|
|
|
|
public final Map<EntityHuman, WorldMap.WorldMapHumanTracker> j = Maps.newHashMap(); // Spigot private -> public
|
|
|
|
private final Map<String, MapIconBanner> k = Maps.newHashMap();
|
|
|
|
public Map<String, MapIcon> decorations = Maps.newLinkedHashMap();
|
2016-04-30 08:04:12 +08:00
|
|
|
+ private org.bukkit.craftbukkit.map.RenderData vanillaRender = new org.bukkit.craftbukkit.map.RenderData(); // Paper
|
|
|
|
|
|
|
|
// CraftBukkit start
|
|
|
|
public final CraftMapView mapView;
|
2018-07-16 23:34:55 +08:00
|
|
|
@@ -41,6 +42,7 @@ public class WorldMap extends PersistentBase {
|
2016-04-30 08:04:12 +08:00
|
|
|
// CraftBukkit start
|
|
|
|
mapView = new CraftMapView(this);
|
|
|
|
server = (CraftServer) org.bukkit.Bukkit.getServer();
|
|
|
|
+ vanillaRender.buffer = colors; // Paper
|
|
|
|
// CraftBukkit end
|
|
|
|
}
|
|
|
|
|
2018-07-16 23:34:55 +08:00
|
|
|
@@ -105,6 +107,7 @@ public class WorldMap extends PersistentBase {
|
|
|
|
this.k.put(mapiconbanner.f(), mapiconbanner);
|
|
|
|
this.a(mapiconbanner.c(), (GeneratorAccess) null, mapiconbanner.f(), (double) mapiconbanner.a().getX(), (double) mapiconbanner.a().getZ(), 180.0D, mapiconbanner.d());
|
2016-04-30 08:04:12 +08:00
|
|
|
}
|
|
|
|
+ vanillaRender.buffer = colors; // Paper
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-07-16 23:34:55 +08:00
|
|
|
@@ -148,6 +151,7 @@ public class WorldMap extends PersistentBase {
|
2016-05-12 10:07:46 +08:00
|
|
|
return nbttagcompound;
|
2016-04-30 08:04:12 +08:00
|
|
|
}
|
|
|
|
|
2016-07-28 06:46:02 +08:00
|
|
|
+ public void updateSeenPlayers(EntityHuman entityhuman, ItemStack itemstack) { a(entityhuman, itemstack); } // Paper - OBFHELPER
|
2016-04-30 08:04:12 +08:00
|
|
|
public void a(EntityHuman entityhuman, ItemStack itemstack) {
|
2018-07-16 23:34:55 +08:00
|
|
|
if (!this.j.containsKey(entityhuman)) {
|
2016-04-30 08:04:12 +08:00
|
|
|
WorldMap.WorldMapHumanTracker worldmap_worldmaphumantracker = new WorldMap.WorldMapHumanTracker(entityhuman);
|
2018-07-16 23:34:55 +08:00
|
|
|
@@ -361,6 +365,21 @@ public class WorldMap extends PersistentBase {
|
2016-04-30 08:04:12 +08:00
|
|
|
|
|
|
|
public class WorldMapHumanTracker {
|
|
|
|
|
|
|
|
+ // Paper start
|
|
|
|
+ private void addSeenPlayers(java.util.Collection<MapIcon> icons) {
|
|
|
|
+ org.bukkit.entity.Player player = (org.bukkit.entity.Player) trackee.getBukkitEntity();
|
|
|
|
+ WorldMap.this.decorations.forEach((uuid, mapIcon) -> {
|
|
|
|
+ // If this cursor is for a player check visibility with vanish system
|
|
|
|
+ org.bukkit.entity.Player other = org.bukkit.Bukkit.getPlayer(uuid); // Spigot
|
|
|
|
+ if (other == null || player.canSee(other)) {
|
|
|
|
+ icons.add(mapIcon);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ private boolean shouldUseVanillaMap() {
|
|
|
|
+ return mapView.getRenderers().size() == 1 && mapView.getRenderers().get(0).getClass() == org.bukkit.craftbukkit.map.CraftMapRenderer.class;
|
|
|
|
+ }
|
|
|
|
+ // Paper stop
|
|
|
|
public final EntityHuman trackee;
|
|
|
|
private boolean d = true;
|
2016-06-09 11:57:14 +08:00
|
|
|
private int e;
|
2018-07-16 23:34:55 +08:00
|
|
|
@@ -377,9 +396,12 @@ public class WorldMap extends PersistentBase {
|
2016-11-17 10:23:38 +08:00
|
|
|
@Nullable
|
2016-04-30 08:04:12 +08:00
|
|
|
public Packet<?> a(ItemStack itemstack) {
|
|
|
|
// CraftBukkit start
|
|
|
|
- org.bukkit.craftbukkit.map.RenderData render = WorldMap.this.mapView.render((org.bukkit.craftbukkit.entity.CraftPlayer) this.trackee.getBukkitEntity()); // CraftBukkit
|
|
|
|
+ if (!this.d && this.i % 5 != 0) { this.i++; return null; } // Paper - this won't end up sending, so don't render it!
|
|
|
|
+ boolean vanillaMaps = shouldUseVanillaMap(); // Paper
|
|
|
|
+ org.bukkit.craftbukkit.map.RenderData render = !vanillaMaps ? WorldMap.this.mapView.render((org.bukkit.craftbukkit.entity.CraftPlayer) this.trackee.getBukkitEntity()) : WorldMap.this.vanillaRender; // CraftBukkit // Paper
|
|
|
|
|
|
|
|
java.util.Collection<MapIcon> icons = new java.util.ArrayList<MapIcon>();
|
|
|
|
+ if (vanillaMaps) addSeenPlayers(icons); // Paper
|
|
|
|
|
|
|
|
for ( org.bukkit.map.MapCursor cursor : render.cursors) {
|
|
|
|
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/map/RenderData.java b/src/main/java/org/bukkit/craftbukkit/map/RenderData.java
|
2018-01-18 14:00:51 +08:00
|
|
|
index 256a13178..5768cd512 100644
|
2016-04-30 08:04:12 +08:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/map/RenderData.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/map/RenderData.java
|
|
|
|
@@ -5,7 +5,7 @@ import org.bukkit.map.MapCursor;
|
|
|
|
|
|
|
|
public class RenderData {
|
|
|
|
|
|
|
|
- public final byte[] buffer;
|
|
|
|
+ public byte[] buffer; // Paper
|
|
|
|
public final ArrayList<MapCursor> cursors;
|
|
|
|
|
|
|
|
public RenderData() {
|
|
|
|
--
|
2018-07-16 23:34:55 +08:00
|
|
|
2.17.1
|
2016-04-30 08:04:12 +08:00
|
|
|
|