Permalink
Browse files

Fallback to a modern material name on legacy item conversion.

If a script incorrectly uses a modern material name with a data value, we should still try and correct for that.
  • Loading branch information...
PseudoKnight committed Aug 29, 2018
1 parent 03e94bf commit 18205c10320a12daeff6920e54758a9487898f5b
Showing with 6 additions and 4 deletions.
  1. +6 −4 src/main/java/com/laytonsmith/core/ObjectGenerator.java
@@ -307,8 +307,11 @@ public MCItemStack item(Construct i, Target t, boolean legacy) {
}
}
if(material == null || material.getName().equals("AIR")) {
throw new CREFormatException("Could not find legacy item material from \"" + mat + "\""
+ " with data \"" + data + "\"", t);
material = StaticLayer.GetMaterial(mat); // try modern material just in case
if(material == null) {
throw new CREFormatException("Could not find legacy item material from \"" + mat + "\""
+ " with data \"" + data + "\"", t);
}
}
// convert legacy meta to material
@@ -1190,8 +1193,7 @@ public CArray enchants(Map<MCEnchantment, Integer> map, Target t) {
if(setype.equals("SWEEPING")) {
// data from 1.11.2, changed in 1.12
etype = StaticLayer.GetEnchantmentByName("SWEEPING_EDGE");
}
if(etype == null) {
} else {
throw new CREEnchantmentException("Unknown enchantment type: " + setype, t);
}
}

0 comments on commit 18205c1

Please sign in to comment.