Permalink
Browse files

Also try converting legacy material names in data_name()

  • Loading branch information...
PseudoKnight committed Aug 8, 2018
1 parent 6944aba commit e11b715ac698b76876d4cd423ab713b067f541ec
Showing with 12 additions and 3 deletions.
  1. +12 −3 src/main/java/com/laytonsmith/core/functions/Minecraft.java
@@ -180,8 +180,8 @@ public String getName() {
@Override
public String docs() {
return "string {item} Returns a modern material for the a legacy item id, notation, or array."
+ "If an invalid argument is passed in, null is returned."
return "string {item} Returns a modern material for the a legacy item id, name, notation, or array."
+ " If an invalid argument is passed in, null is returned."
+ " Given 1 or '1:0', returns 'STONE'."
+ " Given an item array with {name: STONE, data: 1}, returns 'GRANITE'.";
}
@@ -227,7 +227,16 @@ public Construct exec(Target t, Environment environment, Construct... args) thro
return new CString(is.getType().getName(), t);
}
if(i == -1) {
i = Static.getInt32(args[0], t);
try {
i = Static.getInt32(args[0], t);
} catch (CRECastException ex) {
// possibly a material name
MCMaterial mat = StaticLayer.GetConvertor().GetMaterialFromLegacy(args[0].val(), 0);
if(mat == null) {
return CNull.NULL;
}
return new CString(mat.getName(), t);
}
}
if(i2 == -1) {
i2 = 0;

0 comments on commit e11b715

Please sign in to comment.