2020-05-06 11:48:49 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2016-04-30 02:04:12 +02: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
|
2020-06-25 13:00:35 +02:00
|
|
|
index 94eab21f0defe90e7ad169c45de1fdd002f35f7a..d1cf7602a0c47723593be11c030d3c819426d4d4 100644
|
2016-04-30 02:04:12 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/EntityHuman.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
|
2020-06-25 13:00:35 +02:00
|
|
|
@@ -595,6 +595,12 @@ public abstract class EntityHuman extends EntityLiving {
|
2016-04-30 02:04:12 +02:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
// CraftBukkit end
|
|
|
|
+ // Paper start - remove player from map on drop
|
|
|
|
+ if (itemstack.getItem() == Items.FILLED_MAP) {
|
2018-07-18 02:37:30 +02:00
|
|
|
+ WorldMap worldmap = ItemWorldMap.getSavedMap(itemstack, this.world);
|
2016-04-30 02:04:12 +02:00
|
|
|
+ worldmap.updateSeenPlayers(this, itemstack);
|
|
|
|
+ }
|
2019-04-27 05:05:36 +02:00
|
|
|
+ // Paper end
|
2016-04-30 02:04:12 +02:00
|
|
|
|
2019-04-27 05:05:36 +02:00
|
|
|
return entityitem;
|
|
|
|
}
|
2016-04-30 02:04:12 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/WorldMap.java b/src/main/java/net/minecraft/server/WorldMap.java
|
2020-06-25 13:00:35 +02:00
|
|
|
index e6d97e7ffae3eadac586bad078123cd4aaa69916..225353e072033d1e5aaf5604b8db255d9a154dc8 100644
|
2016-04-30 02:04:12 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/WorldMap.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/WorldMap.java
|
2020-06-25 13:00:35 +02:00
|
|
|
@@ -36,6 +36,7 @@ public class WorldMap extends PersistentBase {
|
|
|
|
private final Map<String, MapIconBanner> m = Maps.newHashMap();
|
2019-04-27 05:05:36 +02:00
|
|
|
public final Map<String, MapIcon> decorations = Maps.newLinkedHashMap();
|
2020-06-25 13:00:35 +02:00
|
|
|
private final Map<String, WorldMapFrame> n = Maps.newHashMap();
|
2016-04-30 02:04:12 +02:00
|
|
|
+ private org.bukkit.craftbukkit.map.RenderData vanillaRender = new org.bukkit.craftbukkit.map.RenderData(); // Paper
|
|
|
|
|
|
|
|
// CraftBukkit start
|
|
|
|
public final CraftMapView mapView;
|
2020-06-25 13:00:35 +02:00
|
|
|
@@ -48,6 +49,7 @@ public class WorldMap extends PersistentBase {
|
2016-04-30 02:04:12 +02:00
|
|
|
// CraftBukkit start
|
|
|
|
mapView = new CraftMapView(this);
|
|
|
|
server = (CraftServer) org.bukkit.Bukkit.getServer();
|
|
|
|
+ vanillaRender.buffer = colors; // Paper
|
|
|
|
// CraftBukkit end
|
|
|
|
}
|
|
|
|
|
2019-06-25 03:47:58 +02:00
|
|
|
@@ -115,6 +117,7 @@ public class WorldMap extends PersistentBase {
|
2020-06-25 13:00:35 +02:00
|
|
|
this.m.put(mapiconbanner.f(), mapiconbanner);
|
|
|
|
this.a(mapiconbanner.c(), (GeneratorAccess) null, mapiconbanner.f(), (double) mapiconbanner.a().getX(), (double) mapiconbanner.a().getZ(), 180.0D, mapiconbanner.d());
|
|
|
|
}
|
|
|
|
+ this.vanillaRender.buffer = colors; // Paper
|
2016-04-30 02:04:12 +02:00
|
|
|
|
2020-06-25 13:00:35 +02:00
|
|
|
NBTTagList nbttaglist1 = nbttagcompound.getList("frames", 10);
|
2016-04-30 02:04:12 +02:00
|
|
|
|
2020-06-25 13:00:35 +02:00
|
|
|
@@ -195,6 +198,7 @@ public class WorldMap extends PersistentBase {
|
2019-04-27 05:05:36 +02:00
|
|
|
this.b();
|
2016-04-30 02:04:12 +02:00
|
|
|
}
|
|
|
|
|
2019-04-27 05:05:36 +02:00
|
|
|
+ public void updateSeenPlayers(EntityHuman entityhuman, ItemStack itemstack) { this.a(entityhuman, itemstack); } // Paper - OBFHELPER
|
2016-04-30 02:04:12 +02:00
|
|
|
public void a(EntityHuman entityhuman, ItemStack itemstack) {
|
2018-12-17 06:18:06 +01:00
|
|
|
if (!this.humans.containsKey(entityhuman)) {
|
2016-04-30 02:04:12 +02:00
|
|
|
WorldMap.WorldMapHumanTracker worldmap_worldmaphumantracker = new WorldMap.WorldMapHumanTracker(entityhuman);
|
2020-06-25 13:00:35 +02:00
|
|
|
@@ -430,6 +434,21 @@ public class WorldMap extends PersistentBase {
|
2016-04-30 02:04:12 +02: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();
|
2018-08-26 20:11:49 +02:00
|
|
|
+ WorldMap.this.decorations.forEach((name, mapIcon) -> {
|
2016-04-30 02:04:12 +02:00
|
|
|
+ // If this cursor is for a player check visibility with vanish system
|
2018-08-26 20:11:49 +02:00
|
|
|
+ org.bukkit.entity.Player other = org.bukkit.Bukkit.getPlayerExact(name); // Spigot
|
2016-04-30 02:04:12 +02:00
|
|
|
+ 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;
|
|
|
|
+ }
|
2019-04-27 05:05:36 +02:00
|
|
|
+ // Paper end
|
2016-04-30 02:04:12 +02:00
|
|
|
public final EntityHuman trackee;
|
|
|
|
private boolean d = true;
|
2016-06-09 05:57:14 +02:00
|
|
|
private int e;
|
2020-06-25 13:00:35 +02:00
|
|
|
@@ -446,9 +465,12 @@ public class WorldMap extends PersistentBase {
|
2016-11-17 03:23:38 +01:00
|
|
|
@Nullable
|
2016-04-30 02:04:12 +02: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) {
|
|
|
|
|
2019-04-27 05:05:36 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java
|
2020-06-25 13:00:35 +02:00
|
|
|
index e2dfe047e64257b861fa0b168d2790605f09291c..6fb4c273b4ce2bafe8ba42f1f9e8b0d7838e5804 100644
|
2019-04-27 05:05:36 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/WorldServer.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/WorldServer.java
|
2020-06-25 13:00:35 +02:00
|
|
|
@@ -1013,6 +1013,7 @@ public class WorldServer extends World implements GeneratorAccessSeed {
|
2019-04-27 05:05:36 +02:00
|
|
|
{
|
|
|
|
if ( iter.next().trackee == entity )
|
|
|
|
{
|
|
|
|
+ map.decorations.remove(entity.getDisplayName().getString()); // Paper
|
|
|
|
iter.remove();
|
|
|
|
}
|
|
|
|
}
|
2016-04-30 02:04:12 +02:00
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/map/RenderData.java b/src/main/java/org/bukkit/craftbukkit/map/RenderData.java
|
2020-05-06 11:48:49 +02:00
|
|
|
index 256a131781721c86dd6cdbc329335964570cbe8c..5768cd512ec166f1e8d1f4a28792015347297c3f 100644
|
2016-04-30 02:04:12 +02: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() {
|