mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-27 23:10:16 +01:00
SPIGOT-5551: BlockState.setData fails when used by legacy plugin
This commit is contained in:
parent
ab13a117a9
commit
b1e96bd5ca
2 changed files with 16 additions and 8 deletions
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue