geforkt von Mirrors/Paper
1358d1e914
Upstream has released updates that appear 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: 881e06e5 PR-725: Add Item Unlimited Lifetime APIs CraftBukkit Changes: 74c08312 SPIGOT-6962: Call EntityChangeBlockEvent when when FallingBlockEntity starts to fall 64db5126 SPIGOT-6959: Make /loot command ignore empty items for spawn 2d760831 Increase outdated build delay 9ed7e4fb SPIGOT-6138, SPIGOT-6415: Don't call CreatureSpawnEvent after cross-dimensional travel fc4ad813 SPIGOT-6895: Trees grown with applyBoneMeal() don't fire the StructureGrowthEvent 59733a2e SPIGOT-6961: Actually return a copy of the ItemMeta Spigot Changes: ffceeae3 SPIGOT-6956: Drop unload queue patch as attempt at fixing stop issue e19ddabd PR-1011: Add Item Unlimited Lifetime APIs 34d40b0e SPIGOT-2942: give command fires PlayerDropItemEvent, cancelling it causes Item Duplication
145 Zeilen
7.7 KiB
Diff
145 Zeilen
7.7 KiB
Diff
From 0000000000000000000000000000000000000000 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/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
index 317ae71b8b9318a8bfe243b7b316f84566b88bf9..9769977c9db77aa52b99b793ca4f5d0c7b54528f 100644
|
|
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
|
|
@@ -2057,6 +2057,7 @@ public class ServerLevel extends Level implements WorldGenLevel {
|
|
{
|
|
if ( iter.next().player == entity )
|
|
{
|
|
+ map.decorations.remove(entity.getName().getString()); // Paper
|
|
iter.remove();
|
|
}
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java
|
|
index 067513b240db88b818bd26d74c31fb5f8ee80f5d..df753a2d39332464f16207615175bc95d35f61e8 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/player/Player.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java
|
|
@@ -88,6 +88,7 @@ import net.minecraft.world.item.ElytraItem;
|
|
import net.minecraft.world.item.ItemCooldowns;
|
|
import net.minecraft.world.item.ItemStack;
|
|
import net.minecraft.world.item.Items;
|
|
+import net.minecraft.world.item.MapItem; // Paper
|
|
import net.minecraft.world.item.ProjectileWeaponItem;
|
|
import net.minecraft.world.item.SwordItem;
|
|
import net.minecraft.world.item.crafting.Recipe;
|
|
@@ -106,6 +107,7 @@ import net.minecraft.world.level.block.entity.SignBlockEntity;
|
|
import net.minecraft.world.level.block.entity.StructureBlockEntity;
|
|
import net.minecraft.world.level.block.state.BlockState;
|
|
import net.minecraft.world.level.block.state.pattern.BlockInWorld;
|
|
+import net.minecraft.world.level.saveddata.maps.MapItemSavedData; // Paper
|
|
import net.minecraft.world.phys.AABB;
|
|
import net.minecraft.world.phys.Vec3;
|
|
import net.minecraft.world.scores.PlayerTeam;
|
|
@@ -750,6 +752,14 @@ public abstract class Player extends LivingEntity {
|
|
return null;
|
|
}
|
|
// CraftBukkit end
|
|
+ // Paper start - remove player from map on drop
|
|
+ if (itemstack.getItem() == Items.FILLED_MAP) {
|
|
+ MapItemSavedData worldmap = MapItem.getSavedData(itemstack, this.level);
|
|
+ if (worldmap != null) {
|
|
+ worldmap.tickCarriedBy(this, itemstack);
|
|
+ }
|
|
+ }
|
|
+ // Paper end
|
|
|
|
return entityitem;
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java b/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java
|
|
index 3527d40102d512d0e276edc969ea3c189aa34ec2..913fabc7f42c05ccec6501247a5e8d1d481756ee 100644
|
|
--- a/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java
|
|
+++ b/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java
|
|
@@ -63,6 +63,7 @@ public class MapItemSavedData extends SavedData {
|
|
public final Map<String, MapDecoration> decorations = Maps.newLinkedHashMap();
|
|
private final Map<String, MapFrame> frameMarkers = Maps.newHashMap();
|
|
private int trackedDecorationCount;
|
|
+ private org.bukkit.craftbukkit.map.RenderData vanillaRender = new org.bukkit.craftbukkit.map.RenderData(); // Paper
|
|
|
|
// CraftBukkit start
|
|
public final CraftMapView mapView;
|
|
@@ -83,6 +84,7 @@ public class MapItemSavedData extends SavedData {
|
|
// CraftBukkit start
|
|
this.mapView = new CraftMapView(this);
|
|
this.server = (CraftServer) org.bukkit.Bukkit.getServer();
|
|
+ this.vanillaRender.buffer = colors; // Paper
|
|
// CraftBukkit end
|
|
}
|
|
|
|
@@ -138,6 +140,7 @@ public class MapItemSavedData extends SavedData {
|
|
if (abyte.length == 16384) {
|
|
worldmap.colors = abyte;
|
|
}
|
|
+ worldmap.vanillaRender.buffer = abyte; // Paper
|
|
|
|
ListTag nbttaglist = nbt.getList("banners", 10);
|
|
|
|
@@ -548,6 +551,21 @@ public class MapItemSavedData extends SavedData {
|
|
|
|
public class HoldingPlayer {
|
|
|
|
+ // Paper start
|
|
+ private void addSeenPlayers(java.util.Collection<MapDecoration> icons) {
|
|
+ org.bukkit.entity.Player player = (org.bukkit.entity.Player) this.player.getBukkitEntity();
|
|
+ MapItemSavedData.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 end
|
|
public final Player player;
|
|
private boolean dirtyData = true;
|
|
private int minDirtyX;
|
|
@@ -581,7 +599,9 @@ public class MapItemSavedData extends SavedData {
|
|
@Nullable
|
|
Packet<?> nextUpdatePacket(int mapId) {
|
|
MapItemSavedData.MapPatch worldmap_b;
|
|
- org.bukkit.craftbukkit.map.RenderData render = MapItemSavedData.this.mapView.render((org.bukkit.craftbukkit.entity.CraftPlayer) this.player.getBukkitEntity()); // CraftBukkit
|
|
+ if (!this.dirtyData && this.tick % 5 != 0) { this.tick++; 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 ? MapItemSavedData.this.mapView.render((org.bukkit.craftbukkit.entity.CraftPlayer) this.player.getBukkitEntity()) : MapItemSavedData.this.vanillaRender; // CraftBukkit // Paper
|
|
|
|
if (this.dirtyData) {
|
|
this.dirtyData = false;
|
|
@@ -597,6 +617,8 @@ public class MapItemSavedData extends SavedData {
|
|
// CraftBukkit start
|
|
java.util.Collection<MapDecoration> icons = new java.util.ArrayList<MapDecoration>();
|
|
|
|
+ if (vanillaMaps) addSeenPlayers(icons); // Paper
|
|
+
|
|
for (org.bukkit.map.MapCursor cursor : render.cursors) {
|
|
if (cursor.isVisible()) {
|
|
icons.add(new MapDecoration(MapDecoration.Type.byIcon(cursor.getRawType()), cursor.getX(), cursor.getY(), cursor.getDirection(), PaperAdventure.asVanilla(cursor.caption()))); // Paper - Adventure
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/map/RenderData.java b/src/main/java/org/bukkit/craftbukkit/map/RenderData.java
|
|
index 256a131781721c86dd6cdbc329335964570cbe8c..5768cd512ec166f1e8d1f4a28792015347297c3f 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() {
|