SPIGOT-7376: Exception with getBlockData when hasBlockData is false

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot 2023-06-08 21:19:44 +10:00
parent 99be5d2a3c
commit f990d547f7

View File

@ -45,6 +45,7 @@ import net.minecraft.nbt.NBTTagString;
import net.minecraft.network.chat.IChatBaseComponent;
import net.minecraft.world.entity.EnumItemSlot;
import net.minecraft.world.item.ItemBlock;
import net.minecraft.world.level.block.state.IBlockData;
import org.apache.commons.lang.Validate;
import org.apache.commons.lang3.EnumUtils;
import org.bukkit.Material;
@ -911,12 +912,13 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable, BlockDataMeta {
@Override
public boolean hasBlockData() {
return this.blockData != null;
return this.blockData != null;
}
@Override
public BlockData getBlockData(Material material) {
return CraftBlockData.fromData(ItemBlock.getBlockState(CraftMagicNumbers.getBlock(material).defaultBlockState(), blockData));
IBlockData defaultData = CraftMagicNumbers.getBlock(material).defaultBlockState();
return CraftBlockData.fromData((hasBlockData()) ? ItemBlock.getBlockState(defaultData, blockData) : defaultData);
}
@Override