From 5a3182ea5532ee582da2a92fd776871bcd8a3667 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Sun, 21 Aug 2016 17:22:32 +1000 Subject: [PATCH] Fixes #250 --- core/src/main/java/com/boydti/fawe/Fawe.java | 6 +++-- .../world/registry/BundledBlockData.java | 23 ++++++++++++++++++- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/com/boydti/fawe/Fawe.java b/core/src/main/java/com/boydti/fawe/Fawe.java index 47daf9a1..f482088a 100644 --- a/core/src/main/java/com/boydti/fawe/Fawe.java +++ b/core/src/main/java/com/boydti/fawe/Fawe.java @@ -283,8 +283,10 @@ public class Fawe { File extraBlocks = MainUtil.copyFile(jar, "extrablocks.json", null); if (extraBlocks != null && extraBlocks.exists()) { try { - BundledBlockData.getInstance().add(extraBlocks.toURI().toURL(), false); - } catch (Throwable ignore) {} + BundledBlockData.getInstance().add(extraBlocks.toURI().toURL(), true); + } catch (Throwable ignore) { + Fawe.debug("Invalid format: extrablocks.json"); + } } } diff --git a/core/src/main/java/com/sk89q/worldedit/world/registry/BundledBlockData.java b/core/src/main/java/com/sk89q/worldedit/world/registry/BundledBlockData.java index 36c7699d..7eb90039 100644 --- a/core/src/main/java/com/sk89q/worldedit/world/registry/BundledBlockData.java +++ b/core/src/main/java/com/sk89q/worldedit/world/registry/BundledBlockData.java @@ -96,10 +96,27 @@ public class BundledBlockData { } public boolean add(BlockEntry entry, boolean overwrite) { + if (entry == null) { + return false; + } entry.postDeserialization(); if (!overwrite && (idMap.containsKey(entry.id) || legacyMap[entry.legacyId] != null)) { return false; } + if (entry.states != null) { + FaweState half = entry.states.get("half"); + if (half != null && half.values != null) { + FaweStateValue top = half.values.get("top"); + FaweStateValue bot = half.values.get("bottom"); + if (top != null && top.getDirection() == null) { + top.setDirection(new Vector(0, 1, 0)); + } + if (bot != null && bot.getDirection() == null) { + bot.setDirection(new Vector(0, -1, 0)); + } + } + } + idMap.put(entry.id, entry); legacyMap[entry.legacyId] = entry; return true; @@ -245,6 +262,10 @@ public class BundledBlockData { } } + public void setDirection(Vector direction) { + this.direction = direction; + } + @Override public Vector getDirection() { return direction; @@ -255,7 +276,7 @@ public class BundledBlockData { public class FaweState implements State { public Byte dataMask; - private Map values; + public Map values; @Override public Map valueMap() {