13
0
geforkt von Mirrors/Paper

SPIGOT-4253: Add way to prioritise item conversion

Dieser Commit ist enthalten in:
md_5 2018-08-11 17:43:41 +10:00
Ursprung 29e7564874
Commit 96778caabb
2 geänderte Dateien mit 19 neuen und 2 gelöschten Zeilen

Datei anzeigen

@ -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);

Datei anzeigen

@ -134,6 +134,11 @@ public final class CraftMagicNumbers implements UnsafeValues {
return CraftLegacy.fromLegacy(material);
}
@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));