3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-18 04:20:08 +01:00

SPIGOT-5551: BlockState.setData fails when used by legacy plugin

Dieser Commit ist enthalten in:
md_5 2020-01-29 09:22:43 +11:00
Ursprung ab13a117a9
Commit b1e96bd5ca
2 geänderte Dateien mit 16 neuen und 8 gelöschten Zeilen

Datei anzeigen

@ -90,7 +90,7 @@ public final class CraftLegacy {
return (mappedData == null) ? new MaterialData(Material.LEGACY_AIR) : mappedData;
}
public static IBlockData fromLegacyData(Material material, Block block, byte data) {
public static IBlockData fromLegacyData(Material material, byte data) {
Preconditions.checkArgument(material.isLegacy(), "fromLegacyData on modern Material");
MaterialData materialData = new MaterialData(material, data);
@ -107,11 +107,11 @@ public final class CraftLegacy {
return convertedBlock.getBlockData();
}
// Return existing block
return block.getBlockData();
// Return air
return Blocks.AIR.getBlockData();
}
public static Item fromLegacyData(Material material, Item item, short data) {
public static Item fromLegacyData(Material material, short data) {
Preconditions.checkArgument(material.isLegacy(), "fromLegacyData on modern Material. Did you forget to define api-version: 1.13 in your plugin.yml?");
MaterialData materialData = new MaterialData(material, (byte) data);
@ -137,8 +137,8 @@ public final class CraftLegacy {
}
}
// Return existing item
return item;
// Return air
return Items.AIR;
}
public static byte toLegacyData(IBlockData blockData) {

Datei anzeigen

@ -56,7 +56,7 @@ public final class CraftMagicNumbers implements UnsafeValues {
}
public static IBlockData getBlock(Material material, byte data) {
return CraftLegacy.fromLegacyData(CraftLegacy.toLegacy(material), getBlock(material), data);
return CraftLegacy.fromLegacyData(CraftLegacy.toLegacy(material), data);
}
public static MaterialData getMaterial(IBlockData data) {
@ -65,7 +65,7 @@ public final class CraftMagicNumbers implements UnsafeValues {
public static Item getItem(Material material, short data) {
if (material.isLegacy()) {
return CraftLegacy.fromLegacyData(CraftLegacy.toLegacy(material), getItem(material), data);
return CraftLegacy.fromLegacyData(CraftLegacy.toLegacy(material), data);
}
return getItem(material);
@ -114,10 +114,18 @@ public final class CraftMagicNumbers implements UnsafeValues {
}
public static Item getItem(Material material) {
if (material != null && material.isLegacy()) {
material = CraftLegacy.fromLegacy(material);
}
return MATERIAL_ITEM.get(material);
}
public static Block getBlock(Material material) {
if (material != null && material.isLegacy()) {
material = CraftLegacy.fromLegacy(material);
}
return MATERIAL_BLOCK.get(material);
}