summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/bukkit/craftbukkit/util/CraftLegacy.java16
-rw-r--r--src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java5
2 files changed, 19 insertions, 2 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftLegacy.java b/src/main/java/org/bukkit/craftbukkit/util/CraftLegacy.java
index 83ac79f7..15f24e9d 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftLegacy.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftLegacy.java
@@ -163,6 +163,10 @@ public class CraftLegacy {
}
public static Material fromLegacy(MaterialData materialData) {
+ return fromLegacy(materialData, false);
+ }
+
+ public static Material fromLegacy(MaterialData materialData, boolean itemPriority) {
Material material = materialData.getItemType();
if (material == null || !material.isLegacy()) {
return material;
@@ -170,7 +174,15 @@ public class CraftLegacy {
Material mappedData = null;
- if (material.isBlock()) {
+ // Try item first
+ if (itemPriority) {
+ Item item = materialToItem.get(materialData);
+ if (item != null) {
+ mappedData = CraftMagicNumbers.getMaterial(item);
+ }
+ }
+
+ if (mappedData == null && material.isBlock()) {
// Try exact match first
IBlockData iblock = materialToData.get(materialData);
if (iblock != null) {
@@ -187,7 +199,7 @@ public class CraftLegacy {
}
// Fallback to matching item
- if (mappedData == null) {
+ if (!itemPriority && mappedData == null) {
Item item = materialToItem.get(materialData);
if (item != null) {
mappedData = CraftMagicNumbers.getMaterial(item);
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
index 3474536f..21d0062d 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java
@@ -135,6 +135,11 @@ public final class CraftMagicNumbers implements UnsafeValues {
}
@Override
+ public Material fromLegacy(MaterialData material, boolean itemPriority) {
+ return CraftLegacy.fromLegacy(material, itemPriority);
+ }
+
+ @Override
public BlockData fromLegacy(Material material, byte data) {
return CraftBlockData.fromData(getBlock(material, data));
}