mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-29 11:42:55 +01:00
9df2066642
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: dfe1fb48 PR-906: Add missing MinecraftExperimental annotation to Bundles 825ab30d PR-905: Add missing MapCursor.Type and update documentation e03d10e6 PR-903: Make BARRIER Waterlogged 1961ead6 PR-898: Use Java Consumer instead of Bukkit Consumer CraftBukkit Changes: f71a799f0 Make BARRIER Waterlogged 172f76a45 Upgrade specialsource-maven-plugin f0702775c SPIGOT-7486: Alternate approach to null profile names 069495671 SPIGOT-7485: Allow air entity items since required for Vanilla logic 5dfd33dc2 SPIGOT-7484: Cancelling PlayerEditBookEvent does not update client's book contents 02d490788 PR-1250: Standardize and centralize Bukkit / Minecraft registry conversion 9024a09b9 PR-1251: Use Java Consumer instead of Bukkit Consumer 6d4b25bf1 Increase diff stability
49 lines
2.8 KiB
Diff
49 lines
2.8 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: miclebrick <miclebrick@outlook.com>
|
|
Date: Thu, 23 Aug 2018 11:45:32 -0400
|
|
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/world/level/block/state/BlockBehaviour.java b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
|
|
index 6c171199dcc30f56a6d0ab7ecf398b505d145067..916d7b35145345cb3bf5ca46df38eae0512c4e95 100644
|
|
--- a/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
|
|
+++ b/src/main/java/net/minecraft/world/level/block/state/BlockBehaviour.java
|
|
@@ -809,6 +809,14 @@ public abstract class BlockBehaviour implements FeatureElement {
|
|
this.replaceable = blockbase_info.replaceable;
|
|
this.conditionallyFullOpaque = this.isOpaque() & this.isTransparentOnSomeFaces(); // Paper
|
|
}
|
|
+ // Paper start - impl cached craft block data, lazy load to fix issue with loading at the wrong time
|
|
+ private org.bukkit.craftbukkit.block.data.CraftBlockData cachedCraftBlockData;
|
|
+
|
|
+ public org.bukkit.craftbukkit.block.data.CraftBlockData createCraftBlockData() {
|
|
+ if (cachedCraftBlockData == null) cachedCraftBlockData = org.bukkit.craftbukkit.block.data.CraftBlockData.createData(asState());
|
|
+ return (org.bukkit.craftbukkit.block.data.CraftBlockData) cachedCraftBlockData.clone();
|
|
+ }
|
|
+ // Paper end
|
|
|
|
private boolean calculateSolid() {
|
|
if (((Block) this.owner).properties.forceSolidOn) {
|
|
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 bb3ebf590e3e6aa6d9ac892095d58b926d2fa50d..777539309639569d9057e4de86c3957a7a72a47f 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/block/data/CraftBlockData.java
|
|
@@ -561,7 +561,17 @@ public class CraftBlockData implements BlockData {
|
|
return craft;
|
|
}
|
|
|
|
+ // Paper start - optimize creating BlockData to not need a map lookup
|
|
+ static {
|
|
+ // Initialize cached data for all IBlockData instances after registration
|
|
+ Block.BLOCK_STATE_REGISTRY.iterator().forEachRemaining(net.minecraft.world.level.block.state.BlockState::createCraftBlockData);
|
|
+ }
|
|
public static CraftBlockData fromData(net.minecraft.world.level.block.state.BlockState data) {
|
|
+ return data.createCraftBlockData();
|
|
+ }
|
|
+
|
|
+ public static CraftBlockData createData(net.minecraft.world.level.block.state.BlockState data) {
|
|
+ // Paper end
|
|
return CraftBlockData.MAP.getOrDefault(data.getBlock().getClass(), CraftBlockData::new).apply(data);
|
|
}
|
|
|