Skip to content

Commit

Permalink
Convert old enchantment value SWEEPING to SWEEPING_EDGE
Browse files Browse the repository at this point in the history
  • Loading branch information
PseudoKnight committed Jul 31, 2017
1 parent 1d00e5b commit 45ff87e
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/main/java/com/laytonsmith/core/ObjectGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,13 @@ public MCItemStack item(Construct i, Target t) {
}
MCEnchantment etype = StaticLayer.GetEnchantmentByName(setype);
if(etype == null){
throw new CREFormatException("Invalid enchantment array etype: \"" + setype + "\".", t);
if(setype.equals("SWEEPING")) {
// data from 1.11.2, changed in 1.12
etype = StaticLayer.GetEnchantmentByName("SWEEPING_EDGE");
}
if(etype == null){
throw new CREFormatException("Invalid enchantment array etype: \"" + setype + "\".", t);
}
}
enchants.put(etype, elevel);
} catch (ClassCastException e) {
Expand Down Expand Up @@ -1019,10 +1025,17 @@ public Map<MCEnchantment,Integer> enchants(CArray enchantArray, Target t) {
for (String key : enchantArray.stringKeySet()) {
try {
CArray ea = (CArray) enchantArray.get(key, t);
MCEnchantment etype = StaticLayer.GetConvertor().GetEnchantmentByName(ea.get("etype", t).val());
String setype = ea.get("etype", t).val();
MCEnchantment etype = StaticLayer.GetConvertor().GetEnchantmentByName(setype);
int elevel = Static.getInt32(ea.get("elevel", t), t);
if (etype == null) {
throw new CREEnchantmentException("Unknown enchantment type at " + key, t);
if(setype.equals("SWEEPING")) {
// data from 1.11.2, changed in 1.12
etype = StaticLayer.GetEnchantmentByName("SWEEPING_EDGE");
}
if(etype == null) {
throw new CREEnchantmentException("Unknown enchantment type at " + key, t);
}
}
ret.put(etype, elevel);
} catch (ClassCastException cce) {
Expand Down

0 comments on commit 45ff87e

Please sign in to comment.