检查是否可以使用Minecraft Forge 1.8.9放置物品

时间:2020-07-08 21:44:36

标签: java minecraft minecraft-forge

我正在尝试检查是否可以放置物品。我首先检查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;
    }
}

有没有可以执行我想要实现的功能的功能?如果没有,那么最好的方法是什么?

0 个答案:

没有答案