我正在尝试检查是否可以放置物品。我首先检查ItemStack是否为块,但它错过了一些项,例如甘蔗,下疣等。我无法找到isPlaceable函数或可以与instanceof一起使用的任何接口。
现在我正在这样做:
BlockPos blockPos = mc.objectMouseOver.getBlockPos();
ItemStack itemInUse = mc.thePlayer.getHeldItem();
if (itemInUse != null) {
Block resultBlock = Block.getBlockFromItem(itemInUse.getItem());
if (mc.theWorld.getBlockState(blockPos).getBlock().getMaterial() == Material.air || resultBlock == null) {
return;
}
}
有没有可以执行我想要实现的功能的功能?如果没有,那么最好的方法是什么?