Further work on items

This commit is contained in:
Matthew Miller
2018-06-14 11:55:02 +10:00
parent 001a3544fb
commit 1cc735e359
11 changed files with 36 additions and 57 deletions

View File

@@ -290,7 +290,7 @@ public class BaseBlock extends Block implements TileEntityBlock {
return "";
}
Tag idTag = nbtData.getValue().get("id");
if (idTag != null && idTag instanceof StringTag) {
if (idTag instanceof StringTag) {
return ((StringTag) idTag).getValue();
} else {
return "";
@@ -413,7 +413,7 @@ public class BaseBlock extends Block implements TileEntityBlock {
* @return true if equal
*/
public boolean equalsFuzzy(BaseBlock o) {
return (getType() == o.getType()) && (getData() == o.getData() || getData() == -1 || o.getData() == -1);
return (getType().equals(o.getType())) && (getData() == o.getData() || getData() == -1 || o.getData() == -1);
}
/**

View File

@@ -26,6 +26,10 @@ public class BlockType {
private String id;
public BlockType(String id) {
// If it has no namespace, assume minecraft.
if (!id.contains(":")) {
id = "minecraft:" + id;
}
this.id = id;
}

View File

@@ -587,6 +587,10 @@ public class BlockTypes {
@Nullable
public static BlockType getBlockType(String id) {
// If it has no namespace, assume minecraft.
if (id != null && !id.contains(":")) {
id = "minecraft:" + id;
}
return blockMapping.get(id);
}
}

View File

@@ -26,6 +26,10 @@ public class ItemType {
private String id;
public ItemType(String id) {
// If it has no namespace, assume minecraft.
if (!id.contains(":")) {
id = "minecraft:" + id;
}
this.id = id;
}

View File

@@ -766,6 +766,10 @@ public class ItemTypes {
@Nullable
public static ItemType getItemType(String id) {
// If it has no namespace, assume minecraft.
if (id != null && !id.contains(":")) {
id = "minecraft:" + id;
}
return itemMapping.get(id);
}
}