#955: Add test for BlockData class of Material

By: BlackHole <black-hole@live.com>
This commit is contained in:
CraftBukkit/Spigot 2021-11-23 08:07:10 +11:00
parent 0e36e68e8b
commit e3c01e2bf0

View File

@ -20,12 +20,14 @@ import net.minecraft.world.level.block.entity.TileEntityFurnace;
import net.minecraft.world.level.block.state.BlockBase;
import net.minecraft.world.level.block.state.IBlockData;
import net.minecraft.world.phys.MovingObjectPositionBlock;
import org.bukkit.block.data.BlockData;
import org.bukkit.craftbukkit.CraftEquipmentSlot;
import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
import org.bukkit.enchantments.EnchantmentTarget;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.MaterialData;
import org.bukkit.support.AbstractTestingBase;
import org.junit.BeforeClass;
import org.junit.Test;
@ -273,4 +275,15 @@ public class PerMaterialTest extends AbstractTestingBase {
assertThat(material.getEquipmentSlot(), is(expected));
}
}
@Test
public void testBlockDataClass() {
if (material.isBlock()) {
Class<?> expectedClass = material.data;
if (expectedClass != MaterialData.class) {
BlockData blockData = Bukkit.createBlockData(material);
assertTrue(expectedClass + " <> " + blockData.getClass(), expectedClass.isInstance(blockData));
}
}
}
}