Попадание ентити в блок

516
11
39
Всем привет,Спавню ентити ,когда он попадает по блоку должен спавнить мой блок,но игра вылетает,помогите решить

Java:
   @Override
    protected void onImpact(RayTraceResult result) {

        if (!this.world.isRemote) {

            this.world.setEntityState(this, (byte)3);

        
        BlockPos blockpos = result.getBlockPos();
        this.xTile = blockpos.getX();
        this.yTile = blockpos.getY();
        this.zTile = blockpos.getZ();
        IBlockState iblockstate = this.world.getBlockState(blockpos);
        this.inTile = iblockstate.getBlock();
        if (iblockstate.getMaterial() != Material.AIR)
        {
            this.inTile.onEntityCollidedWithBlock(this.world, blockpos, iblockstate, this);
            this.world.setBlockState(blockpos,(IBlockState) BlocksRegister.TOTEM);
        }
        this.setDead();
    }
}
 
516
11
39
Сделал так ,вроде работает
Java:
        if (!this.world.isRemote) {

            this.world.setEntityState(this, (byte)3);

            
        
        BlockPos blockpos = result.getBlockPos();
        this.xTile = blockpos.getX();
        this.yTile = blockpos.getY();
        this.zTile = blockpos.getZ();
        IBlockState iblockstate = this.world.getBlockState(blockpos);
        this.inTile = iblockstate.getBlock();
        if (iblockstate.getMaterial() != Material.AIR)
        {
            this.inTile.onEntityCollidedWithBlock(this.world, blockpos, iblockstate, this);
            this.world.setBlockState(blockpos, BlocksRegister.TOTEM.getDefaultState());
        }
        this.setDead();
    }
 
Сверху