From 43cc35a1cf9d03c4c1177740232d156721713b9a Mon Sep 17 00:00:00 2001 From: Aikar Date: Sat, 25 Aug 2018 00:20:58 -0400 Subject: [PATCH] Updated Upstream (CraftBukkit) 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 CraftBukkit Changes: f41aae40 Remove reflection from CraftBlockData --- ...48-Optimize-CraftBlockData-Creation.patch} | 37 +++++++++---------- work/CraftBukkit | 2 +- 2 files changed, 18 insertions(+), 21 deletions(-) rename Spigot-Server-Patches/{0348-Cached-IBlockData-to-CraftBlockData-conversion.patch => 0348-Optimize-CraftBlockData-Creation.patch} (66%) diff --git a/Spigot-Server-Patches/0348-Cached-IBlockData-to-CraftBlockData-conversion.patch b/Spigot-Server-Patches/0348-Optimize-CraftBlockData-Creation.patch similarity index 66% rename from Spigot-Server-Patches/0348-Cached-IBlockData-to-CraftBlockData-conversion.patch rename to Spigot-Server-Patches/0348-Optimize-CraftBlockData-Creation.patch index 04877e453f..4374921be1 100644 --- a/Spigot-Server-Patches/0348-Cached-IBlockData-to-CraftBlockData-conversion.patch +++ b/Spigot-Server-Patches/0348-Optimize-CraftBlockData-Creation.patch @@ -1,11 +1,13 @@ -From 1782b15268da2e8ebd35dbeb1ae11c957fd7ddf3 Mon Sep 17 00:00:00 2001 +From 74f68b921eaba613b8368d573d6cc02e80d0a2c1 Mon Sep 17 00:00:00 2001 From: miclebrick Date: Thu, 23 Aug 2018 11:45:32 -0400 -Subject: [PATCH] Cached IBlockData to CraftBlockData conversion +Subject: [PATCH] Optimize CraftBlockData Creation +Avoids a hashmap lookup by cacheing a reference to the CraftBlockData +and cloning it when one is needed. diff --git a/src/main/java/net/minecraft/server/BlockData.java b/src/main/java/net/minecraft/server/BlockData.java -index 4dd6c3276..1b226a77e 100644 +index 4dd6c32761..1b226a77e0 100644 --- a/src/main/java/net/minecraft/server/BlockData.java +++ b/src/main/java/net/minecraft/server/BlockData.java @@ -1,6 +1,7 @@ @@ -32,7 +34,7 @@ index 4dd6c3276..1b226a77e 100644 + // Paper end } diff --git a/src/main/java/net/minecraft/server/IBlockData.java b/src/main/java/net/minecraft/server/IBlockData.java -index b57f6efb3..7b1d750f3 100644 +index b57f6efb3a..7b1d750f3a 100644 --- a/src/main/java/net/minecraft/server/IBlockData.java +++ b/src/main/java/net/minecraft/server/IBlockData.java @@ -28,6 +28,8 @@ public interface IBlockData extends IBlockDataHolder { @@ -45,32 +47,27 @@ index b57f6efb3..7b1d750f3 100644 return this.getBlock().n(this); } diff --git a/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java b/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java -index 472e89c43..8d886c719 100644 +index a4f3dd1b03..baaace6937 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java +++ b/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java -@@ -454,6 +454,7 @@ public class CraftBlockData implements BlockData { - register(net.minecraft.server.BlockWitherSkull.class, org.bukkit.craftbukkit.block.impl.CraftWitherSkull.class); - register(net.minecraft.server.BlockWitherSkullWall.class, org.bukkit.craftbukkit.block.impl.CraftWitherSkullWall.class); - register(net.minecraft.server.BlockWoodButton.class, org.bukkit.craftbukkit.block.impl.CraftWoodButton.class); -+ Block.REGISTRY_ID.iterator().forEachRemaining(IBlockData::createCraftBlockData); // Paper - initialize cached data for all IBlockData instances after registration - } - - private static void register(Class nms, Class bukkit) { -@@ -493,7 +494,14 @@ public class CraftBlockData implements BlockData { +@@ -494,7 +494,17 @@ public class CraftBlockData implements BlockData { return craft; } -+ // Paper start - cache block data getting ++ // Paper start - optimize creating BlockData to not need a map lookup ++ static { ++ // Initialize cached data for all IBlockData instances after registration ++ Block.REGISTRY_ID.iterator().forEachRemaining(IBlockData::createCraftBlockData); ++ } public static CraftBlockData fromData(IBlockData data) { + return data.createCraftBlockData(); + } + -+ // Only used by BlockData + public static CraftBlockData createData(IBlockData data) { + // Paper end - Class craft = MAP.get(data.getBlock().getClass()); - if (craft == null) { - craft = CraftBlockData.class; + return MAP.getOrDefault(data.getBlock().getClass(), CraftBlockData::new).apply(data); + } + } -- -2.17.1 +2.18.0 diff --git a/work/CraftBukkit b/work/CraftBukkit index 1bc24337d1..f41aae401e 160000 --- a/work/CraftBukkit +++ b/work/CraftBukkit @@ -1 +1 @@ -Subproject commit 1bc24337d1b48f369273b23ba29db0c9e6a8a8c2 +Subproject commit f41aae401e71f7fe00987da7ac59982016598c00