mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-26 20:46:59 +01:00
SPIGOT-4214: Catch attempts to create BlockData for items
This commit is contained in:
parent
272426acd7
commit
80c43fc1de
@ -417,6 +417,8 @@ public class CraftBlockData implements BlockData {
|
||||
}
|
||||
|
||||
public static CraftBlockData newData(Material material, String data) {
|
||||
Preconditions.checkArgument(material == null || material.isBlock(), "Cannot get data for not block %s", material);
|
||||
|
||||
IBlockData blockData;
|
||||
Block block = CraftMagicNumbers.getBlock(material);
|
||||
|
||||
|
@ -84,6 +84,7 @@ public final class CraftMagicNumbers implements UnsafeValues {
|
||||
|
||||
for (Material material : Material.values()) {
|
||||
MinecraftKey key = key(material);
|
||||
// TODO: only register if block/item?
|
||||
MATERIAL_ITEM.put(material, Item.REGISTRY.get(key));
|
||||
MATERIAL_BLOCK.put(material, Block.REGISTRY.get(key));
|
||||
}
|
||||
|
@ -51,6 +51,16 @@ public class BlockDataTest extends AbstractTestingBase {
|
||||
CraftBlockData.newData(Material.CAKE, cakeTest.toString());
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testItem() {
|
||||
CraftBlockData.newData(Material.DIAMOND_AXE, null);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void testItemParse() {
|
||||
CraftBlockData.newData(null, "minecraft:diamond_axe");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClone() {
|
||||
Cake cakeTest = (Cake) CraftBlockData.fromData(Blocks.CAKE.getBlockData().set(BlockCake.BITES, 3));
|
||||
|
Loading…
Reference in New Issue
Block a user