Permalink
Browse files

Better handle legacy potion data and item conversion

  • Loading branch information...
PseudoKnight committed Aug 24, 2018
1 parent 6ed5358 commit 3283090a1970f0bfc14650ee89835c46a6c45092
@@ -279,8 +279,8 @@ public MCItemStack item(Construct i, Target t, boolean legacy) {
MCMaterial material;
if(item.containsKey("name")) {
mat = item.get("name", t).val();
if(mat.equals("MAP")) {
// special handling, ignore data until later
if(mat.equals("MAP") || mat.equals("POTION")) {
// special handling, ignore data here
material = StaticLayer.GetMaterialFromLegacy(mat, 0);
} else {
material = StaticLayer.GetMaterialFromLegacy(mat, data);
@@ -301,15 +301,16 @@ public MCItemStack item(Construct i, Target t, boolean legacy) {
}
mat = type.val();
int id = Static.getInt32(type, t);
if(id == 358) {
// special map handling, ignore data until later
if(id == 358 || id == 373) {
// special map handling, ignore data here
material = StaticLayer.GetMaterialFromLegacy(id, 0);
} else {
material = StaticLayer.GetMaterialFromLegacy(id, data);
}
}
if(material == null) {
throw new CREFormatException("Could not convert legacy item from " + mat + ":" + data, t);
if(material == null || material.getName().equals("AIR")) {
throw new CREFormatException("Could not find legacy item material from \"" + mat + "\""
+ " with data \"" + data + "\"", t);
}
// convert legacy meta to material
@@ -335,8 +336,8 @@ public MCItemStack item(Construct i, Target t, boolean legacy) {
}
ret = StaticLayer.GetItemStack(material, data, qty);
CHLog.GetLogger().w(CHLog.Tags.DEPRECATION, "Converted \"" + mat + ":" + data + "\"" + " to "
+ material.getName(), t);
CHLog.GetLogger().w(CHLog.Tags.DEPRECATION, "Converted \"" + mat + "\" with data \""
+ data + "\" to " + material.getName(), t);
} else if(item.containsKey("name")) {
mat = item.get("name", t).val();
@@ -354,6 +355,10 @@ public MCItemStack item(Construct i, Target t, boolean legacy) {
throw new CREFormatException("Could not find item material from \"" + mat + "\"", t);
}
if(ret.isEmpty()) {
return ret;
}
if(item.containsKey("meta")) {
ret.setItemMeta(itemMeta(item.get("meta", t), ret.getType(), t));
}
@@ -347,7 +347,7 @@ public String docs() {
+ " | against: a block array of the block being placed against"
+ " | oldblock: the old block type that was replaced"
+ " | location: A locationArray for this block} "
+ "{name|type|data} "
+ "{name} "
+ "{}";
}

0 comments on commit 3283090

Please sign in to comment.