运营商&未定义参数类型BlockState,int

时间:2015-02-02 21:29:53

标签: int minecraft

我正在尝试修复我的Minecraft mod。现在在线: int blockMetaWithoutPoweredBit = state& 0x7的; 它是这样说的:运营商&未定义参数类型BloxkState,int。在Minecraft主要使用“int”之前,现在他们将其更改为BlockState,它取代了所有“int”,因为BlockState在其代码中包含它们。我怎样才能解决这个问题? 我自己已经尝试了很多东西来修复它,但遗憾的是我失败了 块状态是进一步定义块的额外数据..

public void onMinecartPass(World world, EntityMinecart cart, BlockPos pos)
{
    //cm = blockID
    if (world.getBlockState(pos) == ERMBase.monorailPowered)
    {
        BlockState state = getBlockState();

        if ((Boolean)state.equals(POWERED))
        {
            double var24 = Math.sqrt(cart.motionX * cart.motionX + cart.motionZ * cart.motionZ);

            if (var24 < 0.03D)
            {
                cart.motionX *= 0.0D;
                cart.motionY *= 0.0D;
                cart.motionZ *= 0.0D;
            }
            else
            {
                cart.motionX *= 0.5D;
                cart.motionY *= 0.0D;
                cart.motionZ *= 0.5D;
            }
        }
        else
        {
            int blockMetaWithoutPoweredBit = state & 0x7;
            double var41 = Math.sqrt(cart.motionX * cart.motionX + cart.motionZ * cart.motionZ);

            if (var41 > 0.01D)
            {
                double var43 = 0.06D;
                cart.motionX += cart.motionX / var41 * var43;
                cart.motionZ += cart.motionZ / var41 * var43;
            }
            else if (blockMetaWithoutPoweredBit == 1)
            {
                if (world.isBlockIndirectlyGettingPowered(pos) == pos.getX() - 1)
                {
                    cart.motionX = 0.02D;
                }
                else if (world.isBlockIndirectlyGettingPowered(pos) == pos.getX() + 1)
                {
                    cart.motionX = -0.02D;
                }
            }
            else if (blockMetaWithoutPoweredBit == 0)
            {
                if (world.isBlockIndirectlyGettingPowered(pos) == pos.getZ() - 1)
                {
                    cart.motionZ = 0.02D;
                }
                else if (world.isBlockIndirectlyGettingPowered(pos) == pos.getZ() + 1)
                {
                    cart.motionZ = -0.02D;
                }
            }
        }
    }

1 个答案:

答案 0 :(得分:0)

你有

state & 0x7;

试图比较int和BlockState对象,你需要使用&amp;运营商有两个整数。