Update ItemUtil.java
This commit is contained in:
parent
67340033bc
commit
a0f7a2878d
1 changed files with 17 additions and 10 deletions
|
@ -29,19 +29,26 @@ public class ItemUtil {
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static ItemStack fromStackString(String stackString) {
|
public static ItemStack fromStackString(String stackString) {
|
||||||
if (stackString == null || stackString.equals("")) return null;
|
if (stackString == null || stackString.equals("")) {
|
||||||
String[] parts = stackString.split(":");
|
return null;
|
||||||
if (parts.length < 2) return null;
|
}
|
||||||
if (parts.length == 2) {
|
try {
|
||||||
Identifier itemId = new Identifier(stackString);
|
String[] parts = stackString.split(":");
|
||||||
|
if (parts.length < 2) return null;
|
||||||
|
if (parts.length == 2) {
|
||||||
|
Identifier itemId = new Identifier(stackString);
|
||||||
|
Item item = Registry.ITEM.getOrEmpty(itemId).orElse(null);
|
||||||
|
if (item == null) return null;
|
||||||
|
return new ItemStack(item);
|
||||||
|
}
|
||||||
|
Identifier itemId = new Identifier(parts[0], parts[1]);
|
||||||
Item item = Registry.ITEM.getOrEmpty(itemId).orElse(null);
|
Item item = Registry.ITEM.getOrEmpty(itemId).orElse(null);
|
||||||
if (item == null) return null;
|
if (item == null) return null;
|
||||||
return new ItemStack(item);
|
return new ItemStack(item, Integer.valueOf(parts[2]));
|
||||||
|
} catch (Exception ex) {
|
||||||
|
BetterEnd.LOGGER.catching(ex);
|
||||||
}
|
}
|
||||||
Identifier itemId = new Identifier(parts[0], parts[1]);
|
return null;
|
||||||
Item item = Registry.ITEM.getOrEmpty(itemId).orElse(null);
|
|
||||||
if (item == null) return null;
|
|
||||||
return new ItemStack(item, Integer.valueOf(parts[2]));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue