mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-08 20:02:31 +01:00
1e39773b53
Upstream has released updates that appears to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 9d0221aa API to get client side view distance. 9be7f0ea SPIGOT-4395: Additions to PlayerBedEnterEvent. 01e534c6 Minor cosmetic cleanups to imports etc CraftBukkit Changes:96c461b3
API to get client side view distance.e2785f4e
Remove note about development builda8000588
SPIGOT-4395: Additions to PlayerBedEnterEvent. Spigot Changes: 117d4f7e Rebuild patches
145 lines
7.3 KiB
Diff
145 lines
7.3 KiB
Diff
From d415127904d0188d028f30b361d7f5312c5532ca Mon Sep 17 00:00:00 2001
|
|
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
|
|
index d245502286..816854dc2f 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityHuman.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
|
|
@@ -618,6 +618,12 @@ public abstract class EntityHuman extends EntityLiving {
|
|
return null;
|
|
}
|
|
// CraftBukkit end
|
|
+ // Paper start - remove player from map on drop
|
|
+ if (itemstack.getItem() == Items.FILLED_MAP) {
|
|
+ WorldMap worldmap = ItemWorldMap.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
|
|
index c5bfe6630d..4f2d7db378 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityTrackerEntry.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityTrackerEntry.java
|
|
@@ -97,7 +97,7 @@ public class EntityTrackerEntry {
|
|
}
|
|
|
|
// 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
|
|
index 264dc740cb..8aa4138a2e 100644
|
|
--- a/src/main/java/net/minecraft/server/World.java
|
|
+++ b/src/main/java/net/minecraft/server/World.java
|
|
@@ -1122,6 +1122,7 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc
|
|
{
|
|
if ( iter.next().trackee == entity )
|
|
{
|
|
+ map.decorations.remove(entity.getDisplayName().getString()); // Paper
|
|
iter.remove();
|
|
}
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/server/WorldMap.java b/src/main/java/net/minecraft/server/WorldMap.java
|
|
index bf7963b421..338d753500 100644
|
|
--- a/src/main/java/net/minecraft/server/WorldMap.java
|
|
+++ b/src/main/java/net/minecraft/server/WorldMap.java
|
|
@@ -30,6 +30,7 @@ public class WorldMap extends PersistentBase {
|
|
private final Map<String, MapIconBanner> k = Maps.newHashMap();
|
|
public Map<String, MapIcon> decorations = Maps.newLinkedHashMap();
|
|
private final Map<String, WorldMapFrame> l = Maps.newHashMap();
|
|
+ private org.bukkit.craftbukkit.map.RenderData vanillaRender = new org.bukkit.craftbukkit.map.RenderData(); // Paper
|
|
|
|
// CraftBukkit start
|
|
public final CraftMapView mapView;
|
|
@@ -42,6 +43,7 @@ public class WorldMap extends PersistentBase {
|
|
// CraftBukkit start
|
|
mapView = new CraftMapView(this);
|
|
server = (CraftServer) org.bukkit.Bukkit.getServer();
|
|
+ vanillaRender.buffer = colors; // Paper
|
|
// CraftBukkit end
|
|
}
|
|
|
|
@@ -107,6 +109,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());
|
|
}
|
|
+ vanillaRender.buffer = colors; // Paper
|
|
|
|
NBTTagList nbttaglist1 = nbttagcompound.getList("frames", 10);
|
|
|
|
@@ -169,6 +172,7 @@ public class WorldMap extends PersistentBase {
|
|
return nbttagcompound;
|
|
}
|
|
|
|
+ public void updateSeenPlayers(EntityHuman entityhuman, ItemStack itemstack) { a(entityhuman, itemstack); } // Paper - OBFHELPER
|
|
public void a(EntityHuman entityhuman, ItemStack itemstack) {
|
|
if (!this.j.containsKey(entityhuman)) {
|
|
WorldMap.WorldMapHumanTracker worldmap_worldmaphumantracker = new WorldMap.WorldMapHumanTracker(entityhuman);
|
|
@@ -404,6 +408,21 @@ public class WorldMap extends PersistentBase {
|
|
|
|
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((name, mapIcon) -> {
|
|
+ // If this cursor is for a player check visibility with vanish system
|
|
+ org.bukkit.entity.Player other = org.bukkit.Bukkit.getPlayerExact(name); // 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;
|
|
private int e;
|
|
@@ -420,9 +439,12 @@ public class WorldMap extends PersistentBase {
|
|
@Nullable
|
|
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
|
|
index 256a131781..5768cd512e 100644
|
|
--- 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() {
|
|
--
|
|
2.19.1
|
|
|