This commit is contained in:
Jesse Boyd 2016-08-21 17:22:32 +10:00
parent 91b2347b96
commit 5a3182ea55
2 changed files with 26 additions and 3 deletions

View File

@ -283,8 +283,10 @@ public class Fawe {
File extraBlocks = MainUtil.copyFile(jar, "extrablocks.json", null); File extraBlocks = MainUtil.copyFile(jar, "extrablocks.json", null);
if (extraBlocks != null && extraBlocks.exists()) { if (extraBlocks != null && extraBlocks.exists()) {
try { try {
BundledBlockData.getInstance().add(extraBlocks.toURI().toURL(), false); BundledBlockData.getInstance().add(extraBlocks.toURI().toURL(), true);
} catch (Throwable ignore) {} } catch (Throwable ignore) {
Fawe.debug("Invalid format: extrablocks.json");
}
} }
} }

View File

@ -96,10 +96,27 @@ public class BundledBlockData {
} }
public boolean add(BlockEntry entry, boolean overwrite) { public boolean add(BlockEntry entry, boolean overwrite) {
if (entry == null) {
return false;
}
entry.postDeserialization(); entry.postDeserialization();
if (!overwrite && (idMap.containsKey(entry.id) || legacyMap[entry.legacyId] != null)) { if (!overwrite && (idMap.containsKey(entry.id) || legacyMap[entry.legacyId] != null)) {
return false; 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); idMap.put(entry.id, entry);
legacyMap[entry.legacyId] = entry; legacyMap[entry.legacyId] = entry;
return true; return true;
@ -245,6 +262,10 @@ public class BundledBlockData {
} }
} }
public void setDirection(Vector direction) {
this.direction = direction;
}
@Override @Override
public Vector getDirection() { public Vector getDirection() {
return direction; return direction;
@ -255,7 +276,7 @@ public class BundledBlockData {
public class FaweState implements State { public class FaweState implements State {
public Byte dataMask; public Byte dataMask;
private Map<String, FaweStateValue> values; public Map<String, FaweStateValue> values;
@Override @Override
public Map<String, FaweStateValue> valueMap() { public Map<String, FaweStateValue> valueMap() {