From 27ec3cdc6675b0a6e7eb2641e9bfaa50013b02a3 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Sun, 5 Jan 2020 16:17:17 +1100 Subject: [PATCH] idk why we need a lazy reference for an integer here when null would work better --- .../sk89q/worldedit/world/block/BlockType.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockType.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockType.java index 7ee536538..4328788be 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockType.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockType.java @@ -54,8 +54,11 @@ public class BlockType implements FawePattern, Keyed { private final String id; private final BlockTypesCache.Settings settings; - private final LazyReference legacyId = LazyReference.from(() -> computeLegacy(0)); + /* + private final LazyReference legacyId = LazyReference.from(() -> computeLgacy(0)); private final LazyReference legacyData = LazyReference.from(() -> computeLegacy(1)); + */ + private Integer legacyCombinedId; private boolean initItemType; private ItemType itemType; @@ -310,7 +313,7 @@ public class BlockType implements FawePattern, Keyed { @Deprecated public int getLegacyId() { - return legacyId.getValue(); + return computeLegacy(0); } /** @@ -322,11 +325,13 @@ public class BlockType implements FawePattern, Keyed { */ @Deprecated public int getLegacyData() { - return legacyData.getValue(); + return computeLegacy(1); } private int computeLegacy(int index) { - int[] legacy = LegacyMapper.getInstance().getLegacyFromBlock(this.getDefaultState()); - return legacy != null ? legacy[index] : 0; + if (this.legacyCombinedId == null) { + this.legacyCombinedId = LegacyMapper.getInstance().getLegacyCombined(this.getDefaultState()); + } + return index == 0 ? legacyCombinedId >> 4 : legacyCombinedId & 15; } }